hdoj-1197-specialized Four-digit Numbers

Source: Internet
Author: User

Specialized Four-digit NumbersTime limit:2000/1000 MS (java/others) Memory limit:65536/32768 K (java/others)
Total submission (s): 4963 Accepted Submission (s): 3587

Problem Descriptionfind and list all four-digit numbers in decimal notation that has the property, the sum of its fou R digits equals the sum of its digits when represented in hexadecimal (base) notation and also equals the sum of its di Gits 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 + all three representations (including BB016), so 2992 should Be 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

Sourcepacific Northwest 2004
RECOMMENDIGNATIUS.L | We have carefully selected several similar problems for you:1205 1157 1194 1200 1202
#include <stdio.h> bool Judge (int m) {int n=m,res1=0,res2=0,res3=0;while (n) {res1+=n%12;n/=12;} n=m;while (n) { res2+=n%10;n/=10;} N=m;while (n) {res3+=n%16;n/=16;} if (RES1==RES2&&RES2==RES3) return True;return false;} int main () {for (int i=2992;i<=9999;++i) {if (judge (i)) printf ("%d\n", I);} return 0;}

Thought it would time out, actually over, or 0ms
Exe.time Exe.memory Code Len. Language Author
0MS 1380K 408B g++

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

hdoj-1197-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.