575--Skew Binary

#include<stdio.h> #include<string.h> #include<math.h> #define LOCAL int main() { #ifdef LOCAL freopen("in.txt","r",stdin); freopen("out.txt","w",stdout); #endif char s[35]; int i; while(1) { scanf("%s",s); if(s[0]=='0') break; int len=strlen(s); long num=0; for(i=0;i<len;i++) { if(s[i]=='1') { num+=((long)pow(2.0,len-i)-1); ////printf("--------%d/n",num); } if(s[i]=='2') { num+=2*((long)pow(2.0,len-i)-1); ///printf("--------%d/n",num); } } printf("%d/n",num); } return 0; }

你可能感兴趣的:(575--Skew Binary)