首页 > 其他 > 详细

这道题至今没有调对,他告诉我,不确定边界条件,不要瞎写

时间:2018-02-04 12:27:27      阅读:229      评论:0      收藏:0      [点我收藏+]
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
using namespace std;
#define maxn 10000

int mark,cnt;
int su[maxn];

int find(int su[],int s,int n){
    for(int i=0;i<n;i++){
        if(su[i]==s)
        return 1;
    }
    return 0;
}

void getsu(){
    cnt=0;
    for(int i=2;i<maxn;i++){
    mark=1;
    for(int l=2;l<sqrt(i);l++)
    if(i%l==0)    {mark=0;break;}
    
    if(mark==1)
    su[cnt++]=i;
}
}

int main(){
    getsu();
        freopen("UVa_in.txt","r",stdin);
//    freopen("UVa_out.txt","w",stdout);
//    cout<<cnt;
//    cout<<su[0]<<‘ ‘<<su[1]<<‘ ‘<<su[2]<<‘ ‘<<su[3]<<‘ ‘<<su[4];
    int te,ans;
    while(cin>>te && te!=0){
        ans=0;
    for(int i=0;i<cnt/2;i++){
        if(su[i]<(te+1)/2){
        if(find(su,te-su[i],cnt))
        ans++;
    }
    }
    printf("%d\n",ans);
    }
    return 0;
} 

 

这道题至今没有调对,他告诉我,不确定边界条件,不要瞎写

原文:https://www.cnblogs.com/ucandoit/p/8412784.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!