Advertisement
jakaria_hossain

UVA - A Multiplication Game

May 29th, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement