QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#770442#9622. 有限小数ucup-team3294#WA 1ms3668kbC++231.1kb2024-11-21 21:55:092024-11-21 21:55:10

Judging History

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

  • [2024-11-21 21:55:10]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3668kb
  • [2024-11-21 21:55:09]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define x first
#define y second
#define PII pair<int,int>
const int mod=998244353;
set<int>q;
map<int,int>mp;
void solve()
{ 
   int a,b;
   cin>>a>>b;
   //cout<<b<<" ";
   if(mp[b]){
   	    cout<<0<<" "<<1<<"\n";
   	    return;
   }
   int c=1e10,d=0;
   for(auto v:q){
   	  int g=__gcd(v,b);
   	  int B=v/g*b;
   	  int A=a*(B/b);
   	  int g1=B/v;
   	  A%=g1;
   	  A=g1-A;
   	  g=__gcd(A,B);
   	  A/=g,B/=g;
   	  if(B>1e9) continue;
   	  if(A<c){
   	     c=A,d=B;	
	  }
   }
   cout<<a<<" "<<b<<"\n";
 /*  for(int i=0;i<=c;i++){
   	 for(int j=1;j<=1000;j++){
   	     int g=j*b;
		 int m=i*(g/j)+a*(g/b);
		 g=g/__gcd(g,m);
		 if(mp[g]){
		 	cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<i<<" "<<j<<"\n";
		 	return;
		 }	
	 }
   }*/
}
signed main() 
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int T=1;
	cin>>T;
	q.insert(1);
	for(auto u:q){
		int cnt1=u*2,cnt2=u*5;
		if(cnt1<=1e9) q.insert(cnt1);
		if(cnt2<=1e9) q.insert(cnt2);
		mp[u]=1;
	}
//	cout<<q.size()<<" ";
	while(T--)
	{ 
	   solve();
	}
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3668kb

input:

4
1 2
2 3
3 7
19 79

output:

0 1
2 3
3 7
19 79

result:

wrong answer The result is not terminating.(Testcase 2)