QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#480858 | #249. Miller Rabin 算法 | Kalenist# | WA | 19ms | 3744kb | C++20 | 811b | 2024-07-16 19:14:50 | 2024-07-16 19:14:50 |
Judging History
answer
#include<bits/stdc++.h>
#define For(i,a,b) for(register int i=a;i<=b;i++)
#define ull unsigned long long
using namespace std;
int n,a[20];
ull x;
mt19937 rnd(20061130);
inline int get(int l,int r){return rnd()%(r-l+1)+l;}
inline ull mul(ull a,ull b,ull mod)
{
ull res=a*b-(ull)((long double)a/mod*b+1e-9)*mod;
return res<0?res+mod:res;
}
inline ull fpow(int a,ull b,ull mod)
{
ull res=1;a%=mod;
for(;b;b>>=1,a=mul(a,a,mod))
if(b&1) res=mul(res,a,mod);
return res;
}
inline bool chk(long long x)
{
if(x == 1) return false;
For(i,1,15) if(fpow(a[i],x,x) != a[i]%x)
return false;
return true;
}
int main()
{
For(i,1,15) a[i]=get(100,1000);
while(scanf("%lld",&x) != EOF)
puts(chk(x)?"Y":"N");
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 19ms
memory: 3744kb
input:
996581938833575363 971646509461160317 773155992127361153 161603952726515268 540879144500456953 476831214764178553 784255927154201144 671096087619405061 805545190025269709 339546334309245137 337726347922962343 222956293307015293 809183111090275843 799050063298926344 691718101820598109 646220213113313...
output:
N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N N ...
result:
wrong answer 2nd lines differ - expected: 'Y', found: 'N'