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

简单算法 00000 ~ 11111 测试都正确 为什么wa 大牛指教

Posted by shaohua2208 at 2009-04-21 16:39:15 on Problem 1090
#include<iostream>
#include<math.h>
using namespace std;
int main()
{
	int n;
	int l;
	int num[1005];
	int i;
	freopen("1090.txt","r",stdin);
	int k = 0;
	int sum = 0;
	cin>>n;
	l = 31;
	while(l--){
		k = 0;
		sum = 0;
		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