暴力70分答案错误求助!求dalao帮忙

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

xiaoweiws @ 2019-03-17 17:46:34

输入 3947 输出 2 2 3943 为啥这个点给判错? 求dalao帮忙

#include<bits/stdc++.h>
using namespace std;
int n;
int a[16000]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,....};//这里是质数打表出来的数组

int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    {

         for(int j=1;j<=n;j++)
         {
                for(int k=1;k<=n;k++)
             {
                if(a[i]+a[j]+a[k]==n) 
                 {
                    cout<<a[i]<<" "<<a[j]<<" "<<a[k];
                    return 0;
                 }
                if(a[k]>=n) break;
             }
                if(a[j]>=n) break;
        }

    }
    return 0;
}

by 拥抱我很难嘛 @ 2019-05-06 19:53:03

你的 i,j,k应该从0开始计数吧?


|