HDU 1999 untouchable

Source: Internet
Author: User

/*
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.