fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. typedef long long ll ;
  4.  
  5. int dp[35][25][17][16];
  6. ll p2[36], p3[36], p5[36], p7[36], n;
  7.  
  8. int state(int a, int b, int c, int d) {
  9. if(dp[a][b][c][d] != -1) return dp[a][b][c][d];
  10. ll num = p2[a] * p3[b] * p5[c] * p7[d];
  11. if(num >= n) return 0;
  12. if(!state(a + 1, b, c, d)) return dp[a][b][c][d] = 1;
  13. if(!state(a, b + 1, c, d)) return dp[a][b][c][d] = 1;
  14. if(!state(a, b, c + 1, d)) return dp[a][b][c][d] = 1;
  15. if(!state(a, b, c, d + 1)) return dp[a][b][c][d] = 1;
  16. if(!state(a + 2, b, c, d)) return dp[a][b][c][d] = 1;
  17. if(!state(a + 1, b + 1, c, d)) return dp[a][b][c][d] = 1;
  18. if(!state(a + 3, b, c, d)) return dp[a][b][c][d] = 1;
  19. if(!state(a, b + 2, c, d)) return dp[a][b][c][d] = 1;
  20. return dp[a][b][c][d] = 0;
  21. }
  22. int main() {
  23. int i;
  24. p2[0] = p3[0] = p5[0] = p7[0] = 1;
  25. for(i = 1; i <= 34; i++) {
  26. p2[i] = 2 * p2[i - 1];
  27. p3[i] = 3 * p3[i - 1];
  28. p5[i] = 5 * p5[i - 1];
  29. p7[i] = 7 * p7[i - 1];
  30. }
  31. while( scanf("%lld", &n) != EOF) {
  32. memset(dp, -1, sizeof(dp));
  33. if(state(0, 0, 0, 0)) cout << "Stan wins.\n";
  34. else cout << "Ollie wins.\n";
  35. }
  36. return 0;
  37. }
Success #stdin #stdout 0s 4396KB
stdin
Standard input is empty
stdout
Standard output is empty