Any questions?
Reply Back New Topic
View Topic

哥德巴赫猜想

解题报告 浏览:424 回复:6 赞:5 Started by Xawd 5 months ago

include<iostream>

using namespace std;
int main()
{

int n,i,j,cnt=0,a,b;
cin>>n;
for(i=1;i<=n;i++)
{
    for(j=1;j<=i;j++)
    {
        if(i%j==0)
        cnt++;
    }
    if(cnt==2)//如果是质数,就进入循环找下一个质数 
    {
        cnt=0;
        for(a=n;a>=1;a--)
        {
            for(b=1;b<=a;b++)
            {
            if(a%b==0)
            cnt++;
            }
        if(cnt==2&&i+a==n)
        {
        cout<<i<<' '<<a;return 0;//由于这组数只有一组,所以找到后直接结束    
        }
        cnt=0;//每次都要清零!!!        
        }
        
    } 
 } 
 return 0;

}

View Replies

Replied by XIEMai 4 months ago 赞:0

%%%


Replied by JasonLou 4 months ago 赞:2

厉害


Replied by wangwj 2 months ago 赞:3

不是我可以到达的层次


Replied by lijingyi 2 months ago 赞:2

厉害!


Replied by NoharaShinnosuke 2 months ago 赞:15

楼上什么鬼嘤嘤嘤