/*
Question:
Chinese Translation:
See the red letter (for example, the following)
Solution: Create a table and store the sum of the numbers in an array.
Difficulties: it is written in two for loops. The second for loop mainly explains that the multiplication of two numbers does not exceed the upper limit of the maximum number, the following a [I * j] is mainly used to record the sum of the numbers. At the same time, the upper limit of the array in the maximum value is also guaranteed.
Key Point: Calculate the sum of the numbers within 1000 and create a table
Problem solving person: lingnichong
Solution time:
Problem-solving experience: the error occurred several times at the beginning because the array was too small and the background array was very large. He also said that the random M, so the array should be very large to satisfy the question,. Wrong. try to change it.
*/
Untouchable
Time Limit: 2000/1000 MS (Java/others) memory limit: 65536/32768 K (Java/Others)
Total submission (s): 8447 accepted submission (s): 2183
Problem descriptions (n) is the sum of the true factors of positive integer N, that is, the sum of the factors less than N and Division N. for example, S (12) = 1 + 2 + 3 + 4 + 6 = 16. assume that
If neither m nor S (m) is equal to N, N is considered untouchable.
Input includes multiple groups of data. Input t indicates that there are T groups of data. N (2 <= n <= 1000) is given for one row of data in each group.
Output assume that N is an untouchable number, and the output is yes. Otherwise, no is output.
Sample Input
3258
Sample output
yesyesno
#include<stdio.h>#define MAXN 500000+10int a[MAXN]={0};int main(){int n,t,i,j,m;for(i=1;i<MAXN;i++)for(j=1;j*i<MAXN;j++)a[i*j]+=i;scanf("%d",&t);while(t--){m=0;scanf("%d",&n);for(i=1;i<MAXN;i++){if(a[i]-i==n)m=1;}if(m==0)printf("yes\n");elseprintf("no\n");}return 0;}
HDU 1999 untouchable