SHARE
TWEET

UVA - A Multiplication Game

jakaria_hossain May 29th, 2019 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. typedef long long ll;
  4. bool can_win(ll n,ll p)
  5. {
  6.     if(p * 9 < n && p * 18 >= n)
  7.         return false;
  8.     for(ll i=2; i<=9; i++)
  9.     {
  10.         if(can_win(n,p*i)==false)
  11.             return true;
  12.     }
  13.     return false;
  14. }
  15. int main()
  16. {
  17.     ll n;
  18.     while(cin>>n)
  19.     {
  20.         if (n == 1)
  21.             puts("Ollie wins.");
  22.         else if (n >= 2 && n <= 9)
  23.             puts ("Stan wins.");
  24.         else
  25.         {
  26.             bool c= can_win(n,1);
  27.             if(c)
  28.                 printf("Stan wins.\n");
  29.             else
  30.                 printf("Ollie wins.\n");
  31.         }
  32.  
  33.     }
  34.     return 0;
  35. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top