ZOJ 1712 Skew Binary

简单题

Skew Binary
   
     
1 #include < iostream >
2 #include < string >
3 #include < cmath >
4   using namespace std;
5
6 int main()
7 {
8 string a;
9 long num = 0 ;
10 int count = 1 ;
11 // freopen("test.txt", "r", stdin);
12 while (cin >> a && a != " 0 " )
13 {
14 for ( int i = a.length() - 1 ; i >= 0 ; i -- )
15 {
16 num += (a[i] - ' 0 ' ) * (pow (( double ) 2 , count ++ ) - 1 );
17 }
18 cout << num << endl;
19 num = 0 ;
20 count = 1 ;
21 }
22
23 return 0 ;
24 }

 

你可能感兴趣的:(binary)