| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
网上搜的别人AC的代码,没看懂……import java.io.*;
import java.util.*;
import java.math.*;
public class Main
{
public static void main(String[] args)
{
int i,count;
BigInteger n,ans;
String s;
Scanner cin = new Scanner (System.in);
while(cin.hasNext())
{
n = cin.nextBigInteger();
s = n.toString(2);
count = 0;
for(i=0;i<s.length();i++)
if(s.charAt(i)=='1')
count++;
ans=BigInteger.valueOf(2);
ans = ans.pow(count);
ans = ans.subtract(BigInteger.ONE);
System.out.println(ans);
}
}
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator