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 |
No clue why I get WACan anybody tell me what could be wrong with something like: #include <iostream> #include <vector> using namespace std; int gimme(unsigned long int a){ if (a == 0) return 0; if (a%2 == 1) return 1 + gimme(a/2); else return gimme(a/2); } int main() { unsigned long target = 20; unsigned long startFrom = 0; unsigned long howMany; unsigned long n; unsigned long vueltas, i; cin>>vueltas; n = 1; while(vueltas > 0){ vueltas--; cin>>target; cin>>howMany; cin>>startFrom; if ((startFrom > target)||(startFrom < 1) ||(startFrom + howMany > target + 1)) cout <<"Case "<< n <<": It cannot be solved."<<endl; else{ cout << "Case "<<n<<":"; for (i = startFrom; i<startFrom + howMany; i++) cout << " "<<gimme(i); cout <<endl; } n++; } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator