QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#176226#5377. $N$ 门问题Fy5Fengye0 0ms0kbC++201.1kb2023-09-11 12:50:052023-09-11 12:50:05

Judging History

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

  • [2023-09-11 12:50:05]
  • 评测
  • 测评结果:0
  • 用时:0ms
  • 内存:0kb
  • [2023-09-11 12:50:05]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int __int128
int m,n;
int a[50004],b[50004];
double ans[12]={1.000000,1.000000,0.500000,0.666667,0.625000,0.466667,0.416667,0.342857,0.291667,0.253968,0.225000,0};
inline int read()
{
    int ret=0; char c=getchar();
    while(!isdigit(c)) c=getchar();
    while(isdigit(c)) ret=ret*10+c-'0',c=getchar();
    return ret;
}
inline int exGCD(int a,int b,int&x,int&y)
{
    if(!b) {x=1,y=0; return a;}
    int d=exGCD(b,a%b,y,x);
    y-=(a/b*x); return d;
}
inline int exCRT()
{
    for(int i=1;i<=m;++i) b[i]%=a[i];
    int M=a[1],ret=b[1];
    for(int i=2;i<=m;++i)
    {
        int y,z,d=exGCD(M,a[i],y,z);
        if((b[i]-ret)%d!=0) return -1;
        y=(y*(b[i]-ret)/d)%(a[i]/d);
        ret+=y*M,M=M*a[i]/d;
        ret=(ret%M+M)%M;
    }
    return ret;
}
signed main()
{
    freopen("door.in","r",stdin);
    freopen("door.out","w",stdout);
    m=read(); for(int i=1;i<=m;++i) b[i]=read(),a[i]=read();
    n=exCRT(); if(n<2) {puts("error"); return 0;}
    if(n>10) {puts("0.000000"); return 0;} else printf("%.6lf\n",ans[n]);
    return 0;
}

详细

Subtask #1:

score: 0
Dangerous Syscalls

Test #1:

score: 0
Dangerous Syscalls

input:

1
2 3

output:


result:


Subtask #2:

score: 0
Dangerous Syscalls

Test #6:

score: 0
Dangerous Syscalls

input:

8
1 160005726539569
1 233
0 1
1 2947295521
1 686719856393
1 54289
1 12649337
1 37281334283719577

output:


result:


Subtask #3:

score: 0
Skipped

Dependency #2:

0%

Subtask #4:

score: 0
Skipped

Dependency #3:

0%

Subtask #5:

score: 0
Skipped

Dependency #1:

0%

Subtask #6:

score: 0
Dangerous Syscalls

Test #57:

score: 0
Dangerous Syscalls

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:


result:


Subtask #7:

score: 0
Skipped

Dependency #1:

0%