QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#796714#9622. 有限小数AdisFDWA 37ms3720kbC++141.0kb2024-12-02 00:40:282024-12-02 00:40:29

Judging History

This is the latest submission verdict.

  • [2024-12-02 00:40:29]
  • Judged
  • Verdict: WA
  • Time: 37ms
  • Memory: 3720kb
  • [2024-12-02 00:40:28]
  • Submitted

answer

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

详细

Test #1:

score: 0
Wrong Answer
time: 37ms
memory: 3720kb

input:

4
1 2
2 3
3 7
19 79

output:

0 1
1 3
1 14
3 316
3 316
3 316
3 316
3 316
3 316
3 316
3 316
3 316
3 316
3 316
3 316
3 316
3 316
3 316
3 316
3 316
3 316
3 316
3 316
3 316
3 316
3 316
3 316
3 316
3 316
3 316
3 316
3 316
3 316
3 316
3 316
3 316
3 316
3 316
3 316
3 316
3 316
3 316
3 316
3 316
3 316
3 316
3 316
3 316
3 316
3 316
3 316...

result:

wrong output format Extra information in the output file