QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#796629#9622. 有限小数Catbiscuit#ML 0ms0kbC++20533b2024-12-01 22:33:112024-12-01 22:33:11

Judging History

This is the latest submission verdict.

  • [2024-12-01 22:33:11]
  • Judged
  • Verdict: ML
  • Time: 0ms
  • Memory: 0kb
  • [2024-12-01 22:33:11]
  • 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(c-(a1%c)<ans){
//		cout<<a1<<" "<<b1<<" "<<ans<<endl;
		ans=c-(a1%c);
		ans1=b1;
	}
	if(b2==0){
		dfs(a1*5,b1*5,1);
	}
	dfs(a1*2,b1*2,0);
}
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;
	}
}

詳細信息

Test #1:

score: 0
Memory Limit Exceeded

input:

4
1 2
2 3
3 7
19 79

output:

0 1

result: