QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#36200 | #1863. Yes, Prime Minister | Froggygua | WA | 120ms | 29804kb | C++17 | 787b | 2022-06-25 19:55:38 | 2022-06-25 19:55:39 |
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]=ntp[0]=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+1]){
cout<<2*x+2<<'\n';
}
else if(!ntp[x+x+3]){
cout<<2*x+3<<'\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: 100
Accepted
time: 106ms
memory: 29320kb
input:
10 -2 -1 0 1 2 3 4 5 6 7
output:
6 4 3 2 1 1 2 1 2 1
result:
ok 10 numbers
Test #2:
score: -100
Wrong Answer
time: 120ms
memory: 29804kb
input:
201 -100 -99 -98 -97 -96 -95 -94 -93 -92 -91 -90 -89 -88 -87 -86 -85 -84 -83 -82 -81 -80 -79 -78 -77 -76 -75 -74 -73 -72 -71 -70 -69 -68 -67 -66 -65 -64 -63 -62 -61 -60 -59 -58 -57 -56 -55 -54 -53 -52 -51 -50 -49 -48 -47 -46 -45 -44 -43 -42 -41 -40 -39 -38 -37 -36 -35 -34 -33 -32 -31 -30 -29 -28 -27...
output:
202 -1 199 197 194 193 191 -1 -1 -1 -1 181 178 -1 -1 173 -1 -1 166 -1 163 -1 158 157 -1 -1 151 149 146 -1 142 -1 139 137 134 -1 131 -1 127 -1 122 -1 118 -1 -1 113 -1 109 106 -1 103 101 -1 97 94 -1 -1 89 86 -1 82 -1 79 -1 74 73 71 -1 67 -1 62 61 58 -1 -1 53 -1 -1 46 -1 43 41 38 37 34 -1 31 29 26 -1 2...
result:
wrong answer 2nd numbers differ - expected: '202', found: '-1'