Codechef Problems: Balloon Splash (BOP1)
Problem Statement:
Solution:
Given:
X: Number of balloons Alice has
Y: Number of balloons Bob has
To find: Who wins the game (Game condition: Player with more balloon wins otherwise it is a draw)
to find the solution of the problem we can create all possible scenarios
condition 1: both have equal number of balloons
output : Draw
condition 2: Alice has more balloons than Bob
output : Alice
condition 3: Bob has more balloons than Alice
output : Bob
Code Solution:
#include <bits/stdc++.h>
using namespace std;
int main() {
int x, y;
cin >> x >> y;
if (x == y) {
cout << "Draw" << endl;
} else if (x > y) {
cout << "Alice" << endl;
} else {
cout << "Bob" << endl;
}
return 0;
}
Comments
Post a Comment