QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#712314 | #7624. Mystery of Prime | acansaidong | WA | 13ms | 12912kb | C++20 | 950b | 2024-11-05 15:16:28 | 2024-11-05 15:16:31 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
#define double long double
using namespace std;
const int N=2e5+10,NN=1e6+5;
const int M=0x3f3f3f3f3f3f3f3f;
int a[N],p[NN];
int ans=0,n;
vector<int>v;
void f(int x,int y)
{
ans++;
for(auto i:v)
{
if(p[i+a[y+1]]==1) {a[y]=i;return ;}
}
a[y]=1;
}
signed main()
{
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin>>n;
for(int i=2;i<=3e5;i++) p[i]=1;
for(int i=2;i<=3e5;i++)
{
if(p[i])
{
if(i<=2e5) v.push_back(i);
for(int j=i+i;j<=1e6;j+=i)
{
p[j]=0;
}
}
}
for(int i=1;i<=n;i++) cin>>a[i];
for(int i=2;i<=n;i++)
{
if(p[a[i-1]+a[i]]==0)
{
if(i!=n) f(i-1,i);
else ans++;
}
}
// for(int i=1;i<=n;i++) cerr<<a[i]<<" ";
cout<<ans;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 8ms
memory: 12472kb
input:
6 1 5 1 4 4 1
output:
2
result:
ok 1 number(s): "2"
Test #2:
score: 0
Accepted
time: 9ms
memory: 11688kb
input:
9 30 6 7 12 15 8 20 17 14
output:
4
result:
ok 1 number(s): "4"
Test #3:
score: -100
Wrong Answer
time: 13ms
memory: 12912kb
input:
1568 119 519 706 1003 1317 322 25 1466 816 525 1 1122 38 1511 774 515 274 780 647 230 1602 1051 810 1 1 1232 1 1202 1583 412 1111 168 309 1181 184 1260 491 764 809 1213 804 1470 1 1087 1235 1004 673 1338 1333 1392 1036 1539 268 1 712 727 297 404 1317 36 463 1067 1133 693 931 46 1 100 1608 965 1 1406...
output:
690
result:
wrong answer 1st numbers differ - expected: '733', found: '690'