QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#767530#9622. 有限小数OOBMABTRAMS#WA 1ms3600kbC++17758b2024-11-20 21:11:582024-11-20 21:11:59

Judging History

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

  • [2024-11-20 21:11:59]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3600kb
  • [2024-11-20 21:11:58]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
constexpr int N=1000013;
typedef long long ll;
const ll inf=1e9;
typedef long double ld;
vector<ll>v;
void solve(){
    ll a,b;
    cin>>a>>b;
    ll e=b;
    while(e%2==0)e/=2;
    while(e%5==0)e/=5;
    if(e==1) {
        cout<<1<<' '<<1<<'\n';
        return;
    }
    pair<ll,ll>ans={b-a,b};
    //(ak+c)/b
    for(auto k:v) {
        if(b*k>inf)break;
        ll c=a*k%b;
        c=(b-c)%b;
        ans=min(ans,make_pair(c,b*k));
    }
    cout<<ans.first<<' '<<ans.second<<'\n';
}
//
signed main(){
    for(int i=0;i<=30;i++) {
        ll x=1<<i;
        while(x<=inf)v.push_back(x),x*=5;
    }
    sort(v.begin(), v.end());
    int T=1;cin>>T;
    while(T--) solve();
}

詳細信息

Test #1:

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

input:

4
1 2
2 3
3 7
19 79

output:

1 1
1 3
1 14
3 316

result:

wrong answer Jury found better answer than participant's 0 < 1 (Testcase 1)