暴力过

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

xw001 @ 2016-09-23 13:47:49

#include <stdio.h>
#include <math.h>
int zhi(int x){
    if(x<2)return 0;
    for(int h=2;h<=sqrt(x);h++)
        if(x%h==0)return 0;
    return 1;
}
int main(){
    int i,j,a,n;
    scanf("%d",&n);
    for(i=2;i<n;i++){
        for(j=2;j<n;j++){
            a=n-i-j;
            if(zhi(i)==1 && zhi(j)==1 && zhi(a)==1){
                printf("%d %d %d",i,j,a);
                return 0;
            }
        }
    }
}

by 阮行止 @ 2016-09-23 14:00:47

暴力过了对你没好处,对出题人更没坏处。


by cjy9175192177 @ 2016-10-04 10:23:41

大哥,标签里不就有(枚举,暴力)吗?@ 阮行止


by 百里亦守约_test @ 2016-12-26 07:58:22

写题解啊!


by team109 @ 2019-08-28 22:39:21

考古


|