题解 | #查找组成一个偶数最接近的两个素数#

查找组成一个偶数最接近的两个素数

http://www.nowcoder.com/practice/f8538f9ae3f1484fb137789dec6eedb9

你们的代码怎么这么长鸭

#include<stdio.h>
int fac(int a){
    for(int i=2;i<=a/2;i++)
        if(a%i==0)
            return 0;
    return 1;
}
int main(){
     int n;
    while(~scanf("%d",&n)){
        int max=2,i=2,another=n-i;
        while(i<=another){
            if(fac(i)&&fac(another))max=i;
            i++;
            another--;
        }
        printf("%d\n%d\n",max,n-max);
    }
}
全部评论
很6啊
点赞 回复 分享
发布于 2022-11-11 11:59 上海

相关推荐

今天 11:05
门头沟学院 运营
点赞 评论 收藏
分享
醉蟀:你不干有的是人干
点赞 评论 收藏
分享
06-11 17:39
门头沟学院 Java
小呆呆的大鼻涕:卧槽,用户彻底怒了
点赞 评论 收藏
分享
评论
2
1
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务