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

贴一下,留念超越

Posted by troy24 at 2010-08-06 19:22:43 on Problem 1565
#include<iostream>
#include<string>
#include<math.h>
using namespace std;
long long arr[33];
int main()
{
	ifstream cin("test.txt");
	int j;
	for(j=0;j<32;j++)
	{
		arr[j] = pow(2.0,j+1.0) - 1;
	}
	string str;
	int len,i;
	long long sum;
	while(cin>>str && (str != "0"))
	{
		len = str.length();   sum = 0;
		for(i=0;i<len;i++)
		{
			sum += (str[i] - '0')*arr[len-i-1];
		}
		cout<<sum<<endl;
	}
	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