```
bool canWinNim1(int n) {
return n % 4 != 0;
}
// TLE
bool canWinNim(int n) {
int *p = new (nothrow) int [n];
if (p!=nullptr) {
p[0] = true;
p[1] = true;
p[2] = true;
for (int i=3; i < n; i++)
p[i] = !(p[i-1] && p[i-2] && p[i-3]);
}
int ret = p[n-1];
delete[] p;
return ret;
}
```