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:贴一下,留念超越

Posted by 731371663 at 2011-01-14 00:31:18 on Problem 1565
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:
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