Hdoj (HDU) 2097 Sky Number (System)

Source: Internet
Author: User

Problem Description
Sky grew fond of strange things, and naturally sensitive to numbers, a chance, he found an interesting four-digit 2992, this number, its decimal number, its four-digit sum for 2+9+9+2=22, its hexadecimal number BB0, its four-digit sum is also 22, At the same time, its 12 binary number is 1894, and its four digits and 22, AHA, what a coincidence. Sky is very fond of this four-digit number because of his discovery, so here we name it as Sky number. But to judge such a number is still a little trouble ah, so now you help to determine the number of any decimal four digits, is not the sky number bar.

Input
The input contains some four-bit positive integers, and if 0, the input ends.

Output
If n is a sky number, the output "#n is a sky numbers.", otherwise the output "#n is not a sky digit.". Each result occupies one row. Note: #n表示所读入的n值.

Sample Input
2992
1234
0

Sample Output
2992 is a Sky number.
1234 is not a Sky number.

With the ToString method in the Java integer class, it is easy to convert a 10-binary number to the number of other systems.
Slowly experience the power of Java methods ...

Import Java.util.Scanner;
        public class main{public static void Main (string[] args) {Scanner sc = new Scanner (system.in);
        Char hex[] = {' A ', ' B ', ' C ', ' d ', ' e ', ' f '};
            while (Sc.hasnext ()) {int n10 = Sc.nextint ();
            if (n10==0) {return;
            int a=0;
            int b=0;
            int c=0;
            String Strn16 = integer.tostring (N10, 16);
            String strn12 = integer.tostring (N10, 12);
            int k=n10;
                while (k!=0) {a=a+k%10;
            K=K/10;
            }//system.out.println (a);
            Boolean isnum = true;
                for (int i=0;i<strn16.length (); i++) {isnum = true;
                        for (int j=0;j

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.