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 |
Re:贴一下,留念超越In Reply To:Re:贴一下,留念超越 Posted by:chenanzhi at 2010-10-23 23:48:45 #include<iostream> #include<cstring> using namespace std; int a[40]; void fun() { for(int i=1;i<32;i++) a[i]=1<<i; } int main() { //freopen("in.txt","r",stdin); char s[35]; int i,len,sum; fun(); while(scanf("%s",s)!=EOF) { len=strlen(s); if(len==1&&s[0]=='0') break; sum=0; for(i=0;i<len;i++) { if(s[i]=='0') continue; sum+=(s[i]-'0')*(a[len-i]-1); } printf("%d\n",sum); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator