Specialized Four-digit Numbers

Source: Internet
Author: User

Time limit:2000/1000 MS (java/others) Memory limit:65536/32768 K (java/others)
Total submission (s): 2024 Accepted Submission (s): 1346
problem descriptionfind and list all four-digit numbers in Decimal notation that has the property, the sum of its four digits equals, the sum of its digits when represented in H Exadecimal (base) notation and also equals the sum of its digits when represented in duodecimal (base) notation.
For example, the number 2991 has the sum of (decimal) digits 2+9+9+1 = 21. Since 2991 = 1*1728 + 8*144 + 9*12 + 3, its duodecimal representation is 1893 (a), and these digits also sum up to 21. Hexadecimal 2991 is BAF16, and 11+10+15 = $, so 2991 should was rejected by your program.
The next number (2992), however, have digits that sum to + three representations (including BB016), so 2992 Sho Uld is on the listed output. (We don ' t want decimal numbers with fewer than four digits-excluding leading zeroes-so this 2992 is the first correct Answer.)  
Inputthere is no input for this problem.
Outputyour output is to being 2992 and all larger four-digit numbers this satisfy the requirements (in strictly increasing or Der), each on a separate line with no leading or trailing blanks, ending with a new-line character. There is to is no blank lines in the output. The first few lines of the output is shown below.
Sample Input
There is no input for this problem.
Sample Output
29922993299429952996299729982999
Sourcepacific Northwest 2004
Recommendignatius.l

Idea: Water problem

1#include <cstdio>2 BOOLJudge (intnum)3 {4     intDec=0;5     intduo=0;6     inthex=0;7     inttemp=num;8      while(temp)9     {Tendec+=temp%Ten; OneTemp/=Ten; A     } -  -temp=num; the      while(temp) -     { -duo+=temp% A; -Temp/= A; +     } -  +temp=num; A      while(temp) at     { -hex+=temp% -; -Temp/= -; -     } -     //printf ("%d%d%d", dec,duo,hex); -     if(dec==hex&&hex==duo) in        return true; -     Else  to        return false; + } -  the intMainintargcChar*argv[]) * { $     intA=2991;Panax Notoginseng      while(a<=9999) -     { the         if(Judge (a)) +printf"%d\n", a); Aa++; the          +     } -     return 0; $}
View Code

Specialized Four-digit Numbers

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.