QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#770442 | #9622. 有限小数 | ucup-team3294# | WA | 1ms | 3668kb | C++23 | 1.1kb | 2024-11-21 21:55:09 | 2024-11-21 21:55:10 |
Judging History
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)