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 InputThere is no input for this problem. |
Sample Output29922993299429952996299729982999 |
|
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