不可摸数
不可摸數(shù)
Time Limit: 2000/1000 MS (Java/Others)????Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 10585????Accepted Submission(s): 2734
?
Input 包含多組數(shù)據(jù),首先輸入T,表示有T組數(shù)據(jù).每組數(shù)據(jù)1行給出n(2<=n<=1000)是整數(shù)。?
Output 如果n是不可摸數(shù),輸出yes,否則輸出no?
Sample Input 3 2 5 8?
Sample Output yes yes no代碼:
/* #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; }
?
轉(zhuǎn)載于:https://www.cnblogs.com/handsomecui/p/5056154.html
總結(jié)
- 上一篇: 第三次冲刺12.16
- 下一篇: C# 尝试读取或写入受保护的内存,这通常