why this code below have a different output, would you like to explain it ?
input : 10 3 2 4 2 1 1 1 2 1 3 9 3 9 11 9 12 9 1000 8 11
Code #1 :
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
ll t , limak_max , bob_max , limak_total = 0, bob_total = 0;
cin >> t;
while(t--){
cin >> limak_max >> bob_max;
int i = 1;
while(1){
if(i&1){
limak_total += i;
}
else{
bob_total += i;
}
if(limak_total > limak_max){
cout << "Bob" << '\n';
break;
}
else if(bob_total > bob_max){
cout << "Limak" << '\n';
break;
}
i++;
}
}
}
Code #2 :
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
ll t , limak_max , bob_max , limak_total , bob_total;
cin >> t;
while(t--){
cin >> limak_max >> bob_max;
limak_total = 0;
bob_total= 0;
int i = 1;
while(1){
if(i&1){
limak_total += i;
}
else{
bob_total += i;
}
if(limak_total > limak_max){
cout << "Bob" << '\n';
break;
}
else if(bob_total > bob_max){
cout << "Limak" << '\n';
break;
}
i++;
}
}
}