QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#796634#9622. 有限小数Catbiscuit#RE 0ms0kbC++20555b2024-12-01 22:35:382024-12-01 22:35:44

Judging History

This is the latest submission verdict.

  • [2024-12-01 22:35:44]
  • Judged
  • Verdict: RE
  • Time: 0ms
  • Memory: 0kb
  • [2024-12-01 22:35:38]
  • Submitted

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;
	}
	dfs(a1*2,b1*2,0);
	if(b2==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: