暴力能过!!!能过!!!

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

Hanabi_BNUAZ @ 2017-09-10 22:10:46

#include<bits/stdc++.h>
using namespace std;
int a[20000];
int zhi(int n)
{
    for (int i=2;i*i<=n;i++) if (n%i==0) return 0;
    if (n>1) return 1;
    else return 0;
}
int main()
{
    int n,i,j,k,tot=0,ans;
    bool panduan=false;
    cin>>n;
    for (i=1;i<=n;i++) if (zhi(i)) {tot++;a[tot]=i;}
    for (i=1;i<=tot;i++)
        for (j=i;j<=tot;j++)
            for (k=i;k<=tot;k++)
                if ((a[i]+a[j]+a[k])==n)
                { 
                    cout<<a[i]<<" "<<a[j]<<" "<<a[k]<<endl;    
                    return 0;
                } 
}

by huangxt @ 2017-09-11 20:00:43

暴力是能过


by DR安 @ 2017-09-12 13:17:04

最好别这样


by 三青鸟之翎 @ 2017-09-17 11:10:16

厉害


by _Dreams_ @ 2023-08-04 09:59:19

牛马


|