Bears love candies and games involving eating them. Limak and Bob play the following game. Limak eats 1 candy, then Bob eats 2 candies, then Limak eats 3 candies, then Bob eats 4 candies, and so on. Once someone can't eat what he is supposed to eat, he loses. Limak can eat at most A candies in total (otherwise he would become sick), while Bob can eat at most B candies in total. Who will win the game? Print "Limak" or "Bob" accordingly.
#include <iostream>
using namespace std;
int main()
{
int a, b, i, limka, t, bob;
cin >> t;
while (t--)
{
cin >> a;
cin >> b;
i = 1;
limka = 0, bob = 0;
while (i <= a || i <= b)
{
int p = 0;
p = limka + i;
// cout<<" --"<<p;
if (p <= a) // 4 3
{
limka = limka + i; // can't be 4
}
++i;
int q = 0;
q = bob + i;
// cout<<"--"<<q;
if (q <= b)
{ //1
bob = bob + i; //2
}
++i;
}
if (limka <= a && bob <= b)
{
if (limka > bob)
{
cout << "Limak" << endl;
}
else
cout << "Bob" << endl;
}
}
}