标签:
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 10585 Accepted Submission(s): 2734
代码:
/* #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> using namespace std; const int MAXN=500050; int m[MAXN],dp[MAXN]; int main(){ int n,T_T; scanf("%d",&T_T); memset(m,0,sizeof(m)); memset(dp,0,sizeof(dp)); for(int i=1;i<=MAXN/2;i++) for(int j=i+i;j<MAXN;j+=i) m[j]+=i; for(int i=1;i<MAXN;i++) if(m[i]<=1000)dp[m[i]]=1; while(T_T--){ scanf("%d",&n); if(dp[n])puts("no"); else puts("yes"); } return 0; } */ /* #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> using namespace std; const int MAXN=10010; int dp[MAXN],t[MAXN]; void initial(){ memset(dp,0,sizeof(dp)); memset(t,0,sizeof(t)); dp[0]=dp[1]=1; for(int i=2;i<MAXN;i++){ for(int j=1;j<=i/2;j++){ if(i%j==0)dp[i]+=j; } if(dp[i]<=1000)t[dp[i]]=1; } } int main(){ int n,T_T; initial(); scanf("%d",&T_T); while(T_T--){ scanf("%d",&n); if(t[n])puts("no"); else puts("yes"); } return 0; } */ #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> using namespace std; const int MAXN=1010; int a[MAXN],prime[MAXN]; int jug[MAXN]; void initial(){ int k=0; memset(a,0,sizeof(a)); memset(jug,0,sizeof(jug)); for(int i=2;i<MAXN;i++){ if(!a[i]){ for(int j=i+i;j<MAXN;j+=i){ a[j]=1; } prime[k++]=i; jug[i+1]=1; } } for(int i=0;i<k;i++) for(int j=i+1;j<k;j++){ if(prime[i]+prime[j]+1<=1000) jug[prime[i]+prime[j]+1]=1; } } int main(){ int n,T_T; initial(); scanf("%d",&T_T); while(T_T--){ scanf("%d",&n); if(jug[n])puts("no"); else puts("yes"); } return 0; }
标签:
原文地址:http://www.cnblogs.com/handsomecui/p/5056154.html