Advertisement
Guest User

__task_N

a guest
Jun 22nd, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.55 KB | None | 0 0
  1. //N
  2. #include <bits/stdc++.h>
  3.  
  4. using namespace std;
  5.  
  6. bool win[100001][350];
  7.  
  8. int main()
  9. {
  10.     ios_base::sync_with_stdio(false);
  11.     cin.tie(0);
  12.     cout.tie(0);
  13.     for (int i(1); i <= 100000; ++i)
  14.         for (int k(1); k <= min(i, 349); ++k)
  15.             if (i == k) win[i][k] = true;
  16.             else win[i][k] = !win[i - k][k] || !win[i - k - 1][k + 1];
  17.     int n; cin >> n; int test(0);
  18.     //while (n)
  19.     //{
  20.         while (n)
  21.             {
  22.                 cout << "Case #" << ++test << ": ";
  23.                 cout << (!win[n - 1][1] ? "First" : "Second");
  24.                 cout << " player wins.\n";
  25.                 cin >> n;
  26.             }
  27.     //}
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement