QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#36199 | #1863. Yes, Prime Minister | Froggygua | WA | 100ms | 29724kb | C++17 | 778b | 2022-06-25 19:54:41 | 2022-06-25 19:54:43 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define N 20002000
typedef long long ll;
int T;
bool ntp[N];
int p[N>>2],pn;
void init(int n){
ntp[1]=1;
for(int i=2;i<=n;++i){
if(!ntp[i])p[++pn]=i;
for(int j=1;j<=pn&&p[j]*i<=n;++j){
ntp[p[j]*i]=1;
if(i%p[j]==0)break;
}
}
}
int x;
void Solve(){
cin>>x;
if(x<=0){
x=-x;
if(!ntp[x]){
cout<<2*x+2<<'\n';
}
else if(!ntp[x+x+1]){
cout<<2*x+2<<'\n';
}
else{
cout<<-1<<'\n';
}
}
else{
if(!ntp[x]){
cout<<1<<'\n';
}
else if(!ntp[2*x-1]||!ntp[2*x+1]){
cout<<2<<'\n';
}
else{
cout<<-1<<'\n';
}
}
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
init(20000001);
cin>>T;
while(T--){
Solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 100ms
memory: 29724kb
input:
10 -2 -1 0 1 2 3 4 5 6 7
output:
6 4 2 2 1 1 2 1 2 1
result:
wrong answer 3rd numbers differ - expected: '3', found: '2'