| ||||||||||
| 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 | |||||||||
用java测试都对,为什么wa啊import java.util.*;
import java.math.BigInteger;
public class Main{
static int p(int w,int e)
{
int s=1,q;
for(q=0;q<e;q++) s*=w;
return s;
}
public static void main(String[] args) {
Scanner cin=new Scanner(System.in);
String n;
while(cin.hasNext())
{
n=cin.nextLine();
int l=n.length();
if(l==1) {if(Integer.valueOf(n)==0)System.exit(0);}
else
{
BigInteger sum=new BigInteger("0");
for(int j=0;j<l;j++)
{ int r=(int)n.charAt(j)-'0';
int x=r*(p(2,l-j)-1);
sum=sum.add(new BigInteger(Integer.toString(x)));
}
System.out.println(sum);}
}
}
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator