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 |
为什么会WA??大虾帮忙~~~~#include<iostream> using namespace std; int main() { int n; while(cin>>n) { if(n==0)break; int r=1,sum=0,p=n,g=0; while(p%2==0) { p=p/2;r=r*2;g=1; } while(p%2!=0) { p=p/2;sum+=r/2;r=r*2; } sum-=r/4; if(g==1)cout<<n+r/2-sum<<endl; else cout<<n+r/2<<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