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 shaohua2208 at 2009-04-21 16:40:58 on Problem 1090
In Reply To:简单算法 00000 ~ 11111 测试都正确 为什么wa 大牛指教 Posted by:shaohua2208 at 2009-04-21 16:39:15
#include<iostream>
#include<math.h>
using namespace std;
int main()
{
	__int64 n;
	__int64 num[1005];
	int i;
	int k = 0;
	__int64 sum = 0;
	cin>>n;
	for(i = 0; i < n; i++){
		cin>>num[i];
	}
	for(i = n - 1; i >= 0 ; i--){
		if(num[i] == 1){
			sum += pow(-1.0,k) * (pow(2.0,i + 1) - 1);
			k++;
		}
	}
	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