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 |
太马虎了 代码贴差了 重新来过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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator