QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#176216 | #5377. $N$ 门问题 | NATURAL6 | 5 | 1ms | 3512kb | C++14 | 1.3kb | 2023-09-11 12:41:25 | 2023-09-11 12:41:27 |
answer
#include<bits/stdc++.h>
using namespace std;
inline long long qread()
{
long long a=0,f=1;char ch=getchar();
while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
while(isdigit(ch)){(a*=10)+=(ch^48);ch=getchar();}
return a*f;
}
int m;
long long aa[1010],bb[1010],ans=-1;
inline long long exgcd(long long a,long long b,long long &x,long long &y)
{
if(!b)return x=1,y=0,a;
long long an=exgcd(b,a%b,x,y),t=x;
x=y;y=t-a/b*y;
return an;
}
inline long long excrt()
{
long long x,y,M=bb[1],ans=aa[1],A,B,C,t,BB;
for(int i=2;i<=m;++i)
{
A=M;B=bb[i];C=((aa[i]-ans)%bb[i]+bb[i])%bb[i];
t=exgcd(A,B,x,y);BB=B/t;
x=(__int128)x*C/t%BB;
ans+=x*M;
M*=BB;
ans%=M;
ans+=M;
ans%=M;
}
return ans;
}
int main()
{
// freopen("door.in","r",stdin);
// freopen("door.out","w",stdout);
m=qread();
for(int i=1;i<=m;++i)aa[i]=qread(),bb[i]=qread();
ans=excrt();
if(ans<2)puts("error");
else if(ans<=10)
{
if(ans==2)puts("0.500000");
else if(ans==3)puts("0.666667");
else if(ans==4)puts("0.625000");
else if(ans==5)puts("0.466667");
else if(ans==6)puts("0.416667");
else if(ans==7)puts("0.342857");
else if(ans==8)puts("0.291667");
else if(ans==9)puts("0.253968");
else puts("0.225000");
}
else puts("0.000000");
return 0;
}
详细
Subtask #1:
score: 5
Accepted
Test #1:
score: 5
Accepted
time: 0ms
memory: 3456kb
input:
1 2 3
output:
0.500000
result:
ok single line: '0.500000'
Test #2:
score: 0
Accepted
time: 1ms
memory: 3420kb
input:
1 3 5
output:
0.666667
result:
ok single line: '0.666667'
Test #3:
score: 0
Accepted
time: 1ms
memory: 3428kb
input:
1 4 5
output:
0.625000
result:
ok single line: '0.625000'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3436kb
input:
1 0 4
output:
error
result:
ok single line: 'error'
Test #5:
score: 0
Accepted
time: 1ms
memory: 3432kb
input:
1 1 3
output:
error
result:
ok single line: 'error'
Subtask #2:
score: 0
Wrong Answer
Test #6:
score: 10
Accepted
time: 0ms
memory: 3460kb
input:
8 1 160005726539569 1 233 0 1 1 2947295521 1 686719856393 1 54289 1 12649337 1 37281334283719577
output:
error
result:
ok single line: 'error'
Test #7:
score: 0
Accepted
time: 1ms
memory: 3368kb
input:
10 2 64 0 2 2 512 2 4 2 32 2 16 2 256 0 1 2 8 2 128
output:
0.500000
result:
ok single line: '0.500000'
Test #8:
score: 0
Accepted
time: 0ms
memory: 3416kb
input:
10 3 256 3 16 0 1 3 8 3 512 3 32 3 4 3 128 3 64 1 2
output:
0.666667
result:
ok single line: '0.666667'
Test #9:
score: 0
Accepted
time: 0ms
memory: 3448kb
input:
10 0 2 4 8 0 4 4 256 0 1 4 512 4 32 4 128 4 64 4 16
output:
0.625000
result:
ok single line: '0.625000'
Test #10:
score: 0
Accepted
time: 0ms
memory: 3440kb
input:
10 5 128 5 32 5 16 1 4 0 1 5 64 5 256 5 512 1 2 5 8
output:
0.466667
result:
ok single line: '0.466667'
Test #11:
score: 0
Accepted
time: 1ms
memory: 3416kb
input:
10 6 32 6 16 6 256 6 64 0 1 6 128 0 2 6 512 6 8 2 4
output:
0.416667
result:
ok single line: '0.416667'
Test #12:
score: -10
Wrong Answer
time: 0ms
memory: 3408kb
input:
2 1000000007 1000000008 2 4
output:
0.000000
result:
wrong answer 1st lines differ - expected: 'error', found: '0.000000'
Subtask #3:
score: 0
Skipped
Dependency #2:
0%
Subtask #4:
score: 0
Skipped
Dependency #3:
0%
Subtask #5:
score: 0
Skipped
Dependency #1:
100%
Accepted
Dependency #4:
0%
Subtask #6:
score: 0
Wrong Answer
Test #57:
score: 25
Accepted
time: 0ms
memory: 3456kb
input:
15 15 17 2 3 5 31 4 5 12 29 38 41 3 11 44 47 16 23 11 19 6 13 3 37 1 2 21 43 5 7
output:
0.000000
result:
ok single line: '0.000000'
Test #58:
score: 0
Accepted
time: 0ms
memory: 3512kb
input:
14 10 16 21 37 0 23 0 5 11 17 1 3 17 29 19 31 33 43 6 13 4 7 16 41 9 19 0 11
output:
0.000000
result:
ok single line: '0.000000'
Test #59:
score: 0
Accepted
time: 0ms
memory: 3424kb
input:
14 7 23 2 16 2 19 9 11 2 5 7 13 2 7 25 41 25 31 3 9 7 43 3 37 8 17 9 29
output:
0.000000
result:
ok single line: '0.000000'
Test #60:
score: 0
Accepted
time: 0ms
memory: 3464kb
input:
14 2 13 14 19 38 43 10 17 3 8 21 29 0 9 4 7 2 5 1 37 2 11 5 23 22 31 10 41
output:
0.000000
result:
ok single line: '0.000000'
Test #61:
score: 0
Accepted
time: 0ms
memory: 3412kb
input:
2 543380932 999999999 451172165 1000000000
output:
0.000000
result:
ok single line: '0.000000'
Test #62:
score: 0
Accepted
time: 0ms
memory: 3424kb
input:
15 1 2 9 13 31 37 1 17 0 23 1 3 2 5 17 31 9 11 5 29 4 47 6 7 40 41 1 19 26 43
output:
0.000000
result:
ok single line: '0.000000'
Test #63:
score: -25
Wrong Answer
time: 0ms
memory: 3368kb
input:
50000 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 ...
output:
error
result:
wrong answer 1st lines differ - expected: '0.000000', found: 'error'
Subtask #7:
score: 0
Skipped
Dependency #1:
100%
Accepted
Dependency #2:
0%