HDOJ 2051 Bitset

简介: Problem Description Give you a number on base ten,you should output it on base two.(0 < n < 1000)Input For each case there is a postive number n on base ten, end of file.

Problem Description
Give you a number on base ten,you should output it on base two.(0 < n < 1000)

Input
For each case there is a postive number n on base ten, end of file.

Output
For each case output a number on base two.

Sample Input
1
2
3

Sample Output
1
10
11

就是将一个十进制的数按二进制输出。
JAVA中直接调用Integer.toBinaryString(int i);
以二进制(基数 2)无符号整数形式返回一个整数参数的字符串表示形式。

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(sc.hasNext()){
            int n = sc.nextInt();

            System.out.println(Integer.toBinaryString(n));

        }


    }

}
目录
相关文章
|
12月前
hdoj 4715 Difference Between Primes 素数筛选+二分查找
hdoj 4715 Difference Between Primes 素数筛选+二分查找
35 1
|
12月前
|
算法
hdoj 3732 Ahui Writes Word (多重背包)
来看题目吧,可能有100000个单词,然后只有1000ms,但看包的大小,有10000,这样只能允许nlog(n)的算法,还有,每个单词的价值和花费都很小(不大于十),如果不考虑单词的不同,只考虑价值和花费只有最多100种东西,但如果把这些按多重背包的方法来计算依旧会超时,很容易想到和之前01背包的时间复杂度是一样的。
40 0
HDOJ 1081(ZOJ 1074) To The Max(动态规划)
HDOJ 1081(ZOJ 1074) To The Max(动态规划)
77 0
HDOJ 1081(ZOJ 1074) To The Max(动态规划)
|
Java
HDOJ 2051 Bitset
HDOJ 2051 Bitset
96 0
|
Web App开发 Java 数据安全/隐私保护
HDOJ(HDU) 1563 Find your present!(异或)
HDOJ(HDU) 1563 Find your present!(异或)
233 0
HDOJ(HDU) 2161 Primes(素数打表)
HDOJ(HDU) 2161 Primes(素数打表)
108 0
HDOJ 1335 Basically Speaking(进制转换)
HDOJ 1335 Basically Speaking(进制转换)
91 0
|
Java
HDOJ(HDU) 1720 A+B Coming(进制)
HDOJ(HDU) 1720 A+B Coming(进制)
110 0
HDOJ 1196 Lowest Bit(二进制相关的简单题)
HDOJ 1196 Lowest Bit(二进制相关的简单题)
95 0
|
C语言
HDOJ 1016 Prime Ring Problem素数环【深搜2】
HDOJ 1016 Prime Ring Problem素数环【深搜】
95 0