QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#796635#9622. 有限小数Catbiscuit#RE 0ms0kbC++20546b2024-12-01 22:38:332024-12-01 22:38:34

Judging History

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

  • [2024-12-01 22:38:34]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2024-12-01 22:38:33]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
using namespace std;
int T,a,b,c,ans,ans1;
int dfs(int a1,int b1,bool b2){
	if(b1>1000000000)return 0;
	if(ans==1)return 0;
	if(c-(a1%c)<ans){
//		cout<<a1<<" "<<b1<<" "<<ans<<endl;
		ans=c-(a1%c);
		ans1=b1;
	}
	if(b2==0)dfs(a1*2,b1*2,0);
	dfs(a1*5,b1*5,1);
}
signed main(){
	cin>>T;
	while(T--){
		cin>>a>>b;
		c=b;
		while(!(c%2))c/=2;
		while(!(c%5))c/=5;
		if(c==1){
			cout<<"0 1"<<endl;
			continue;
		}
		ans=c+1;
		dfs(a,b,0);
		cout<<ans<<" "<<ans1<<endl;
	}
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Runtime Error

input:

4
1 2
2 3
3 7
19 79

output:

0 1

result: