Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
简单算法 00000 ~ 11111 测试都正确 为什么wa 大牛指教#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator