标签:hdu1999
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 8354 Accepted Submission(s): 2148
3 2 5 8
yes yes no
被这题虐了千百遍- - 打表将s(n)的值在1000以内的全部找出来,数组开到100万就行的原因是sqrt(100万)=1000,所以若m大于100万,若它是素数的话s(m)=1,否则s(m)>1000;这样一来s(m)在1000以内的数就全部覆盖了。
#include <stdio.h> #include <string.h> #define maxn 1002 int arr[maxn], sum[1000002]; int main() { int n, ok, t, i, addSum = 0, mulSum = 1, j; for(i = 1; i <= 500000; ++i){ for(j = i + i; j <= 1000000; j += i) sum[j] += i; } for(i = 1; i <= 1000000; ++i) if(sum[i] <= 1000) arr[sum[i]] = 1; scanf("%d", &t); while(t--){ scanf("%d", &n); if(arr[n]) printf("no\n"); else printf("yes\n"); } return 0; }
HDU1999 不可摸数 【数论】,布布扣,bubuko.com
标签:hdu1999
原文地址:http://blog.csdn.net/chang_mu/article/details/38311397