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:秒过的水题,成就我的50之梦,嘻嘻In Reply To:秒过的水题,成就我的50之梦,嘻嘻 Posted by:zjc0823 at 2010-04-14 11:32:21 #include<iostream> #include<string.h> using namespace std; int main() { char a[40]; scanf("%s",a); while(strcmp(a,"0")!=0){ int n=strlen(a),x=0; for(int i=0;i<n;i++){ int zz=1; for(int j=0;j<=i;j++) zz*=2; x+=(a[strlen(a)-i-1]-'0')*(zz-1); } printf("%d\n",x); scanf("%s",a); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator