Advertisement
Dennnhhhickk

Untitled

Apr 9th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. typedef long long ll;
  2. struct tt{
  3. ll n;
  4. bool log;
  5. };
  6.  
  7. int main()
  8. {
  9. ll n, m, a[10], sum = 0, mx;
  10. cin >> n >> m;
  11. tt b[90010];
  12. for (int i = 0; i < 90010; i++){
  13. b[i].log = 0;
  14. b[i].n = n;
  15. }
  16. for (int i = 0; i < m; i++){
  17. cin >> a[i];
  18. if (a[i] > mx || i == 0)
  19. mx = a[i];
  20. }
  21. b[0].n = n;
  22. b[0].log = 1;
  23. for (int i = 0; i < 90010; i++){
  24. if (b[i].log && b[i].n)
  25. for (int j = 0; j < m; j++){
  26. b[i + a[j]].log = 1;
  27. b[i + a[j]].n = b[i].n - 1;
  28. }
  29. }
  30. bool bol1 = 0, bol2 = 0;
  31. for (int i = 0; i < 90010; i++){
  32. if (b[i].n == 0 && i % 9 != 0)
  33. bol1 = 1;
  34. if (b[i].n == 0 && i % 9 == 0)
  35. bol2 = 1;
  36. }
  37. if (m % 2 == 0)
  38. if (bol2)
  39. cout << "Gena";
  40. else
  41. cout << "Petya";
  42. else
  43. if (bol1)
  44. cout << "Petya";
  45. else
  46. cout << "Gena";
  47. cout << endl;
  48. return 0;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement