QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#736414#9622. 有限小数fishcathuWA 45ms3712kbC++203.4kb2024-11-12 10:53:562024-11-12 10:53:56

Judging History

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

  • [2024-11-12 10:53:56]
  • 评测
  • 测评结果:WA
  • 用时:45ms
  • 内存:3712kb
  • [2024-11-12 10:53:56]
  • 提交

answer

#include<bits/stdc++.h>
#define ls i<<1
#define rs i<<1|1
#define fi first
#define se second
#define min amin
#define max amax
#define eb emplace_back
using namespace std;
using ll=long long;
using LL=__int128;
using pii=pair<int,int>;
const int N=2E5+10;
const int inf=1E9;
const int p=998244353;
template<typename T=int>T read(){T x;cin>>x;return x;}
template<typename U,typename V>U min(const U &x,const V &y){return x<y?x:y;}
template<typename U,typename V>U max(const U &x,const V &y){return y<x?x:y;}
template<typename U,typename ...V>U min(const U &x,const V &...y){return min(x,min(y...));}
template<typename U,typename ...V>U max(const U &x,const V &...y){return max(x,max(y...));}
template<typename U,typename V>bool cmin(U &x,const V &y){return y<x?x=y,true:false;}
template<typename U,typename V>bool cmax(U &x,const V &y){return x<y?x=y,true:false;}
template<typename U,typename ...V>bool cmin(U &x,const V &...y){return cmin(x,min(y...));}
template<typename U,typename ...V>bool cmax(U &x,const V &...y){return cmax(x,max(y...));}
template<typename T>T qpow(T x,int n){T y(1);for(;n;n>>=1,x*=x)if(n&1)y*=x;return y;}
ll sqrt_floor(const ll &x){ll l=0,r=INT_MAX;while(l+1^r){ll mid=l+r>>1;(x<mid*mid?r:l)=mid;}return l;}
ll sqrt_ceil(const ll &x){ll l=-1,r=INT_MAX;while(l+1^r){ll mid=l+r>>1;(mid*mid<x?l:r)=mid;}return r;}
istream &operator>>(istream &is,LL &x){string a;is>>a;bool k=a[0]=='-';if(k)a=a.substr(1);x=0;for(char &t:a)x=x*10+t-48;if(k)x=-x;return is;}
ostream &operator<<(ostream &os,LL x){if(x<0)os<<'-',x=-x;string a;do a+=x%10|48;while(x/=10);reverse(a.begin(),a.end());return os<<a;}
mt19937 rng(time(0));
struct mint{
    int x;
    mint():x(){}
    mint(const int &x):x(x<0?x+p:x){}
    mint inv()const{return qpow(*this,p-2);}
    mint operator-()const{return mint(x?p-x:x);}
    mint &operator+=(const mint &t){return (x+=t.x)<p?0:x-=p,*this;}
    mint &operator-=(const mint &t){return (x-=t.x)<0?x+=p:0,*this;}
    mint &operator*=(const mint &t){return x=ll(x)*t.x%p,*this;}
    mint &operator/=(const mint &t){return *this*=t.inv();}
    mint operator+(const mint &t)const{return mint(*this)+=t;}
    mint operator-(const mint &t)const{return mint(*this)-=t;}
    mint operator*(const mint &t)const{return mint(*this)*=t;}
    mint operator/(const mint &t)const{return mint(*this)/=t;}
    friend mint operator+(const int &x,const mint &y){return mint(x)+=y;}
    friend mint operator-(const int &x,const mint &y){return mint(x)-=y;}
    friend mint operator*(const int &x,const mint &y){return mint(x)*=y;}
    friend mint operator/(const int &x,const mint &y){return mint(x)/=y;}
    friend istream &operator>>(istream &is,mint &t){return is>>t.x;}
    friend ostream &operator<<(ostream &os,const mint &t){return os<<t.x;}
};

void solve(){
    int a,b;
    cin>>a>>b;
    int c=1;
    for(;b%2==0;b/=2)c*=2;
    for(;b%5==0;b/=5)c*=5;
    if(b==1){
        cout<<"0 1"<<'\n';
        return;
    }
    int t=inf/b,mn=inf,res;
    for(int i=1;i<=t;i*=2){
        for(int j=i;j<=t;j*=5)if(j%c==0){
            ll x=ll(j/c)*a,u=(x/b+1)*b-x,v=b*j,z=__gcd(u,v);
            u/=z;
            v/=z;
            if(cmin(mn,u)){
                res=v;
            }
        }
    }
    cout<<mn<<' '<<res<<'\n';
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int T;
    cin>>T;
    while(T--){
        solve();
    }
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3592kb

input:

4
1 2
2 3
3 7
19 79

output:

0 1
1 3
1 4375
3 316

result:

ok 4 case(s)

Test #2:

score: -100
Wrong Answer
time: 45ms
memory: 3712kb

input:

10000
11 12
28 53
17 60
2 35
17 181
80 123
68 141
79 163
71 99
13 64
33 61
15 32
16 61
11 86
33 74
128 143
40 53
7 23
30 31
5 6
86 181
73 91
13 23
71 81
1 2
7 38
117 160
33 83
129 151
88 153
25 58
16 19
19 141
95 124
43 96
71 139
11 59
106 109
93 152
34 43
17 99
1 57
20 159
16 25
5 73
159 170
172 17...

output:

1 12
1 828125000
1 60
1 7
1 231680000
23 960937500
1 36096000
5 326
1 63360
0 1
1 61000
0 1
1 4880
1 10750
1 18500
1 11714560
1 331250
1 898437500
1 31
1 6
1 289600000
1 455000
1 115000000
1 1265625
0 1
1 1484375
0 1
1 415
1 235937500
1 765000000
1 181250
1 2968750
1 4406250
3 775
1 48
3 347500
1 94...

result:

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