QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#796635 | #9622. 有限小数 | Catbiscuit# | RE | 0ms | 0kb | C++20 | 546b | 2024-12-01 22:38:33 | 2024-12-01 22:38:34 |
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;
}
if(b2==0)dfs(a1*2,b1*2,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