-
Notifications
You must be signed in to change notification settings - Fork 0
/
alicebob.cpp
55 lines (40 loc) · 820 Bytes
/
alicebob.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
//question link
//https://leetcode.com/problems/maximum-subarray
#include <bits/stdc++.h>
using namespace std;
bool divisorGame(int N) {
int x = N/2;
int temp = 0;
if(N == 2)
return true;
if(N == 3)
return false;
while(N>2){
while(N%x != 0){
x--;
}
N-=x;
temp++;
if(temp%2 != 0)
cout <<"alice:" <<x <<" N:"<< N<<endl;
else
{
cout <<"Bob:" <<x <<" N:"<< N<<endl;
}
x--;
cout << x;
}
// cout << temp;
if(temp%2 != 0)
return true;
else
{
return true;
}
return false;
}
int main(){
vector<int> t = {-2,1,-3,4,-1,2,1,-5,4};
cout << divisorGame(4);
return 0;
}