import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;
public class Main {
public static void main(String[] args) throws IOException{
InputStreamReader isr=new InputStreamReader(System.in);
BufferedReader br=new BufferedReader(isr);
StringBuffer sb = new StringBuffer("");
int[]arr =new int [32];
int temp=1;
for(int i=1;i<32;i++){
temp*=2;
arr[i]=temp-1;
}
String m="";
while(true){
m=br.readLine();
if("0".equals(m))
break;
int sum=0;
for(int i=1,j=m.length()-1;j>-1;i++,j--){
sum+=arr[i]*(m.charAt(j)-'0');
}
sb.append(sum).append("\n");
}
System.out.print(sb);
}
}
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;
public class Main {
public static void main(String[] args) throws IOException{
InputStreamReader isr=new InputStreamReader(System.in);
BufferedReader br=new BufferedReader(isr);
StringBuffer sb = new StringBuffer("");
int[]arr =new int [32];
int temp=1;
for(int i=1;i<32;i++){
temp*=2;
arr[i]=temp-1;
}
String m="";
while(true){
m=br.readLine();
if("0".equals(m))
break;
int sum=0;
for(int i=1,j=m.length()-1;j>-1;i++,j--){
sum+=arr[i]*(m.charAt(j)-'0');
}
sb.append(sum).append("\n");
}
System.out.print(sb);
}
}
No comments:
Post a Comment