救救我WA掉的30分QAQAQAQAQAQAQAQ

P1579 哥德巴赫猜想(升级版)

veryimportantperson @ 2019-07-07 18:29:14

#include<iostream>
#include<cmath>
#include<cstdlib> 
using namespace std;
bool a[40000]={0,1,0};
int main()
{
    int n;
    cin>>n;
    for(int i=3;i<=n;i++)
    {
        for(int j=2;j<=sqrt(i);j++)
        {
            if(i%j==0)
            {
                a[i]=1;
                break;
            }
        }
    }
    for(int i=3,flag=1;flag&&i<n;i+=2)
    {
        if(a[i])continue;
        if(i>=n)break;
        for(int j=i;j<n;j++)
        {
            if(a[j])continue;
            if(i+j>=n)break;
            if((n-i-j)<j)break;
            if(a[n-i-j])continue;

            cout<<i<<" "<<j<<" "<<n-i-j;
            flag=0;
            break;
            }
        }

    return 0;
}

by ALICIA_ZAtion @ 2019-07-07 19:38:43

啥子题啊


by YZ_hang @ 2019-07-07 20:30:35

你是哪组数据WA了呀


|