6 条题解

  • 1
    @ 2022-10-02 23:15:32

    //简单
    #include <stdio.h>
    #include <math.h>
    int sushu(int a);
    int main(){
    int x;
    scanf("%d",&x);
    for(int x1=3;x1<=(x/2);x1++){
    int x2=x-x1;
    if(sushu(x1)==1&&sushu(x2)==1)
    printf("%d+%d=%d\n",x1,x2,x);
    }
    return 0;

    }
    int sushu(int a){
    for (int i = 2; i <= sqrt(a); i++) {
    if (a % i == 0)
    return 0;
    }
    return 1;
    }

  • 1

    #define _CRT_SECURE_NO_WARNINGS
    #include<stdio.h>
    int main()
    {
    int n, a, i, x1, x2, t;
    scanf("%d", &n);
    for (i = 2; i <= n / 2; i++)
    {
    t = 1;
    for(a = 2; a < i; a++)
    {
    if (i % a == 0)
    {
    t = 0;
    break;
    }
    }
    if (t == 0)
    continue;
    else
    {
    x1 = i;
    x2 = n - x1;

    for (a = 2; a < x2; a++)
    {
    if (x2 % a == 0)
    {
    t = 2;
    break;
    }
    }
    if (t == 2)
    continue;
    }

    printf("%d+%d=%d\n", x1, x2, n);
    }
    return 0;
    }

  • 0
    @ 2022-10-06 10:52:24

    #include<stdio.h>
    int main()
    {
    int x;
    int y;
    int i = 2, h = 2, s, t;
    scanf("%d", &x);
    y = x;
    for (x; x >= 2; x--)
    {
    i = 2;
    while (i < x)
    {

    if (x % i == 0)
    break;
    else
    i++;
    }
    if (i == x)
    {
    s = i;
    t = y - s;
    h = 2;
    if (t <= s)
    {
    while (h < t)
    {
    if (t % h == 0)
    break;
    else
    h++;
    }
    }
    if (t == h)
    printf("%d+%d=%d\n", t, s, y);
    }

    }
    return 0;
    }

  • -1

    #include <iostream>
    using namespace std;
    int main()
    {
    int x,x1,x2,x11;
    cin>>x;
    x1=2;
    while(x1<=x)
    {int y=2,n;
    while(y<x1)
    {
    if(x1%y==0)
    break;
    y++;
    }
    if(y==x1)
    {
    y=2;
    x2=x-x1;
    while(y<x2)
    {
    if(x2%y==0)
    break;
    y++;
    }
    if(y==x2&&x1<=x2)
    cout<<x1<<"+"<<x2<<"="<<x<<endl;
    }
    x1++;
    }
    return 0;
    }

  • -2

    #include <iostream>
    using namespace std;
    int main()
    {
    int x,x1=2,x2,c=2;
    cin>>x;
    x2=x;
    while(x1<=x/2)
    {
    while(c<=x1-1)
    {
    if(x1%c==0)
    break;
    c++;
    }
    if(c==x1)
    {
    int d=2;
    x2=x-x1;
    while(d<=x2-1)
    {
    if(x2%d==0)
    break;
    d++;
    }
    if(d==x2)

    cout<<x1<<"+"<<x2<<"="<<x<<endl;
    }
    c=2;

    x1++;
    }

    return 0;
    }

  • -3
    #include<iostream>
    #define Yes 1
    #define No -1
    using namespace std;
    
    int is_prime(int x)
    {
        if(x==1)
            return No;
        if(x==2)
            return Yes;
        for(int i=2;i<x;i++)
        {
            if(x%i==0)
                return No;
        }
        return Yes;
    }
    
    void func(int x)
    {
        int flag=x/2;
        for(int i=1;i<=flag;i++)
        {
            if(is_prime(i)==Yes && is_prime(x-i)==Yes)
                cout<<i<<"+"<<x-i<<"="<<x<<endl;
        }
    }
    
    int main()
    {
        int x;
        cin>>x;
        func(x);
    
        system("pause");
        return 0;
    }
    
    
  • 1

A3-4 素数专题:验证哥德巴赫猜想

信息

难度
6
分类
(无)
标签
递交数
2234
已通过
516
通过率
23%
被复制
8
上传者