QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#712568#7624. Mystery of PrimeacansaidongWA 10ms13500kbC++201.3kb2024-11-05 16:11:452024-11-05 16:11:46

Judging History

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

  • [2024-11-05 16:11:46]
  • 评测
  • 测评结果:WA
  • 用时:10ms
  • 内存:13500kb
  • [2024-11-05 16:11:45]
  • 提交

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,int z)
{
    ans++;
    if((a[x]==1||a[z]==1)&&a[x]%2==a[z]%2)
    {
        for(auto i:v)
        {
            if(i>a[x]&&p[a[z]+i-a[x]]==1)
            {
                a[y]=i-a[x];
                return ;
            }  
        }
    }
    for(auto i:v)
    {
        if(i>a[x])
        {
            a[y]=i-a[x];
            return ;
        }  
    }
}

void ff()
{
    ans++;
    for(auto i:v)
    {
        if(i>a[2])
        {
            a[1]=i-a[2];
            return ;
        }  
    }
}


signed main()
{
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>n;
    for(int i=2;i<=1e6;i++) p[i]=1;
    for(int i=2;i<=1e6;i++)
    {
        if(p[i]==1)
        {
            if(i<=9e5) 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];
    if(p[a[2]+a[3]]) ff();
    for(int i=2;i<=n;i++)
    {
        if(p[a[i-1]+a[i]]==0) f(i-1,i,i+1);
    }
    // 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: 10ms
memory: 13500kb

input:

6
1 5 1 4 4 1

output:

2

result:

ok 1 number(s): "2"

Test #2:

score: 0
Accepted
time: 3ms
memory: 13468kb

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: 9ms
memory: 11996kb

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:

903

result:

wrong answer 1st numbers differ - expected: '733', found: '903'