AcWing 3373. BigIntege
原题链接
简单
作者:
还想听你的故事
,
2021-06-03 19:50:30
,
所有人可见
,
阅读 267
import java.util.*;
import java.math.*;
public class Main{
public static void main(String[]args){
Scanner sc=new Scanner(System.in);
while(sc.hasNext()){
String s=sc.next();
BigInteger a=new BigInteger(s);
if("0".equals(s)) System.out.println("0");
else System.out.println(base(a));
}
}
private static String base(BigInteger a){
StringBuilder sb=new StringBuilder();
while(a.compareTo(BigInteger.ZERO)!=0){
sb.append(a.mod(BigInteger.TWO));
a=a.divide(BigInteger.TWO);
}
return sb.reverse().toString();
}
}