-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
422514d
commit ddb44bf
Showing
1 changed file
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
//{ Driver Code Starts | ||
#include <bits/stdc++.h> | ||
using namespace std; | ||
|
||
|
||
// } Driver Code Ends | ||
class Solution { | ||
public: | ||
bool divisorGame(int n) { | ||
// Your Code Start | ||
// Alice will win if `n` is even, as she can always subtract a proper divisor (2) and give Bob an odd number. | ||
// Bob is left with an odd number and can't make a valid move, so Alice wins. | ||
// If `n` is odd, Alice has no valid move, so Bob wins. | ||
return n % 2 == 0; | ||
//Your Code End | ||
} | ||
}; | ||
|
||
//{ Driver Code Starts. | ||
|
||
int main() { | ||
int t; | ||
cin >> t; | ||
while (t--) { | ||
int n; | ||
cin >> n; | ||
|
||
Solution obj; | ||
bool ans = obj.divisorGame(n); | ||
if (ans) | ||
cout << "True" << endl; | ||
else | ||
cout << "False" << endl; | ||
} | ||
return 0; | ||
} | ||
// } Driver Code Ends |