QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#748634#9622. 有限小数xydyyds#Compile Error//C++14730b2024-11-14 20:55:392024-11-14 20:55:45

Judging History

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

  • [2024-11-14 20:55:45]
  • 评测
  • [2024-11-14 20:55:39]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;

using ll = long long;
const int lim = 1e9;
vector<ll> tmp;
int _=[]{
    for(ll t=1;t<=lim;t*=2) {
        for(ll tt=t;tt<=lim;tt*=5) {
            tmp.push_back(tt);
        }
    }
    return 0;
}();

void sol() {
    ll a,b; cin>>a>>b;

    a%=b;
    pair<int,int> ans{lim,lim};
    for(ll y:tmp) {
        ll x=(a*y+b-1)/b;
        ll c=x*b-a*y;
        ll d=b*y;
        ll g=gcd(c,d);
        c/=g,d/=g;
        if(d<=lim) ans=min(ans,pair<int,int>{c,d}); 
    }

    cout<<ans.first<<' '<<ans.second<<endl;
}

int main() {
    cin.tie(nullptr)->sync_with_stdio(false);

    int T; cin>>T;
    while(T--)
        sol();

    return 0;

}

詳細信息

answer.code: In function ‘void sol()’:
answer.code:25:14: error: ‘gcd’ was not declared in this scope
   25 |         ll g=gcd(c,d);
      |              ^~~