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

No clue why I get WA

Posted by terto at 2005-10-11 16:48:35 on Problem 2108
Can 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:
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