# Help in Bear and Candies 123 problem

Hi !! i am solving the bear and candy problem got almost everything correct but I cant able to understand where I went wrong .
////////////////////////////////////////////////////////////
include <bits/stdc++.h>
using namespace std;

void ans(int a,int b){

``````int cnt =1;
int maxi = max(a,b);
int limak=0,bob=0;
while(cnt = (a+b)){

if(cnt%2==1){
limak += cnt;
if(limak>a){
cout<<"Bob"<<endl;
break;
}
}else{
bob+=cnt;
if(bob>b){
cout<<"Limak"<<endl;
}
break;
}
cnt++;
``````

}
}

int main(){
int t;
cin>>t;
while(tâ€“){
int a,b;
cin>>a>>b;
ans(a,b);

``````}

return 0;
``````

}

@pranav_71
Can u send the prb link?

candy problem

when i am running my code it actually not working for one queryy and i cant understand why?

@pranav_71
Here u go buddy i have written the code with much simpler logic .
Hope u will get it , ping me in case u get stuck at any point.

``````#include <iostream>
using namespace std;

int main() {
int t;
cin>>t;
while(t--)
{
int a,b;
cin>>a>>b;
int sma=0,smb=0;
for(int i=1; ;i++)
{
if(i%2==1)
{
sma+=i;
}
else
smb+=i;
if(sma>a)
{
cout<<"Bob";
break;
}
else if(smb>b)
{
cout<<"Limak";
break;
}
}
cout<<endl;
}
return 0;
}
``````

Thanks bro