Help in CANDY123

hey guys…I am trying to solve CANDY123 and i am getting my test cases correct but it gives me wrong answer when i submit. can anybody tell me what test cases should i try to resolve this problem.
Thanks… :slight_smile:


    #include<iostream>
    #include<sstream>
    #include<string>
    #include<limits>

    using namespace std;

    int main()
    {
        int trials = 0;
        cin >> trials;
        cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
        while(trials--)
        {
            int A = 0;
            int B = 0;
            string line;

            getline(cin,line);
      
            stringstream s(line);

            s >> A >> B;

      
            int l = 0;
            int b = 0;
            int candy = 1;
            int turn  = 0;
            while(true)
	    {
	        if (turn)
	        {
	            if(b <= B)
		    {
		        b += candy;
		        turn  = 0;
		    }
	            else
		    { 
		        cout<<"Limark"<<endl;
		        break;
		    }
	        }
	        else
	        {
	            if(l <= A)
		    {
		        l += candy;
		        turn = 1; 
		    }
	            else
		    {
		        cout<<"Bob"<<endl;
		        break;
		    }
	        } 
	        candy++;
	    }
          }
      }

cout<<“Limark”<<endl;

Why are you printing “Limark” when the output asked you to print “Limak” . I suspect that you are getting WA because of this. Correct this and give it a try. If WA persists, get back to us ^^

thanks dude… i have been scratching my head for hours on this…
It worked… :slight_smile:

1 Like

Glad it did the trick :smiley: