QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#767238#9622. 有限小数xjt05Compile Error//C++231018b2024-11-20 20:19:002024-11-20 20:19:00

Judging History

你现在查看的是最新测评结果

  • [2024-11-20 20:19:00]
  • 评测
  • [2024-11-20 20:19:00]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
//lg2=30
//log5=19
ll gcd(ll a,ll b){
	if(b==0)return a;
	else return gcd(b,a%b);
}
ll ksm(ll x,ll y)
{
	ll ans=1;
	while(y)
	{
		if(y&1)
		ans*=x;
		x*=x;
		y>>=1;
	}
	return ans;
}
void solve(){
	ll c=1e18;
	ll a,b;
	__int128 fenmu=0;
	scanf("%lld %lld",&a,&b);
	__int128 u,f;
	u=f=LONG_MAX;
	for(ll i=0;i<=30;i++){
		ll five=1;
		for(ll j=0;j<=13;j++,five*=5){
			__int128 ko;
			ko=a*ksm(2,i)*ksm(5,j);
			if(ko>1e18)
			break;
			__int128 tem=a*(1<<i)*five;
			__int128 m;
			if(tem<=b)
			m=(b/tem);
			else 
			m=(tem/b)+(tem%b>0);
				c = m*b-tem;
				fenmu=b*(1<<i)*five;
				ll k=gcd(c,fenmu);
				if(fenmu/k>(ll)1e9)
				continue;
				if(u>c/k)
				u=c/k,f=fenmu/k;
				else if(u==c/k)
				f=min(f,fenmu/k);
				else 
				continue;
		}
	}
	cout<<(ll)u<<" "<<(ll)f<<"\n";
}

int main(){
	int t;
	scanf("%d",&t);
	while(t--){
		solve();
	}
	
	
	return 0;
}
/*

10
2 35
*/

详细

In file included from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:58,
                 from answer.code:1:
/usr/include/c++/13/numeric: In instantiation of ‘constexpr std::common_type_t<_Tp1, _Tp2> std::gcd(_Mn, _Nn) [with _Mn = long long int; _Nn = __int128; common_type_t<_Tp1, _Tp2> = __int128]’:
answer.code:44:13:   required from here
/usr/include/c++/13/numeric:166:43: error: static assertion failed: std::gcd arguments must be integers
  166 |       static_assert(is_integral_v<_Mn> && is_integral_v<_Nn>,
      |                                           ^~~~~~~~~~~~~~~~~~
/usr/include/c++/13/numeric:166:43: note: ‘std::is_integral_v<__int128>’ evaluates to false
In file included from /usr/include/c++/13/bits/stl_pair.h:60,
                 from /usr/include/c++/13/bits/stl_algobase.h:64,
                 from /usr/include/c++/13/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:51:
/usr/include/c++/13/type_traits: In instantiation of ‘struct std::make_unsigned<__int128>’:
/usr/include/c++/13/type_traits:1983:11:   required by substitution of ‘template<class _Tp> using std::make_unsigned_t = typename std::make_unsigned::type [with _Tp = __int128]’
/usr/include/c++/13/numeric:173:24:   required from ‘constexpr std::common_type_t<_Tp1, _Tp2> std::gcd(_Mn, _Nn) [with _Mn = long long int; _Nn = __int128; common_type_t<_Tp1, _Tp2> = __int128]’
answer.code:44:13:   required from here
/usr/include/c++/13/type_traits:1836:62: error: invalid use of incomplete type ‘class std::__make_unsigned_selector<__int128, false, false>’
 1836 |     { typedef typename __make_unsigned_selector<_Tp>::__type type; };
      |                                                              ^~~~
/usr/include/c++/13/type_traits:1744:11: note: declaration of ‘class std::__make_unsigned_selector<__int128, false, false>’
 1744 |     class __make_unsigned_selector;
      |           ^~~~~~~~~~~~~~~~~~~~~~~~
answer.code: In function ‘void solve()’:
answer.code:26:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   26 |         scanf("%lld %lld",&a,&b);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~
answer.code: In function ‘int main()’:
answer.code:60:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   60 |         scanf("%d",&t);
      |         ~~~~~^~~~~~~~~