斜二进制数
#include<iostream> #include<string> #include<stdio.h> #include<algorithm> #include<cstring> #include<cstdio> #include <math.h> using namespace std; char a[1005]; int main(){ scanf("%s",a); int len = strlen(a); long long sum = 0; for(int i = 0 ; i < len ; i++) { sum += (a[i] -'0') * ( pow(2,len - i) -1); // cout<<sum<<endl; } if(2147483647 < sum) cout<<"too long!"<<endl; else printf("%d\n",sum); //printf("%s\n",a); return 0; }