Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Re:秒过的水题,成就我的50之梦,嘻嘻

Posted by qylsw at 2010-07-10 17:56:13 on Problem 1565
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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator