Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.94 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. typedef long long ll;
  5.  
  6. #define pb push_back
  7. #define ft first
  8. #define sd second
  9. #define all(x) begin((x)), end((x))
  10. #define forn(i, n) for (int (i) = 0; (i) < (n); ++(i))
  11. #define isz(x) (int)(x).size()
  12. /* <-------------------> */
  13.  
  14. const ll MAX = 2e7;
  15. bool us[(int)MAX];
  16. vector<int> p;
  17.  
  18. void solve() {
  19.     for (ll i = 2; i < MAX; ++i) if (!us[i]) {
  20.         p.pb((int)i);
  21.         for (ll j = i * i; j < MAX; j += i) {
  22.             us[j] = true;
  23.         }
  24.     }
  25.     int n, m = isz(p), x = 0;
  26.     cin >> n;
  27.     forn (i, m) while (n % p[i] == 0) {
  28.         x ^= i + 1;
  29.         n /= p[i];
  30.     }
  31.     if (n != 1) {
  32.         cout << "David";
  33.     } else {
  34.         cout << (x ? "David" : "Vasya");
  35.     }
  36. }
  37.  
  38. /* <-------------------> */
  39. // #define LOCAL
  40. int main() {
  41. #ifdef LOCAL
  42.     freopen("input.txt", "r", stdin);
  43. #endif
  44.     ios_base::sync_with_stdio(0);
  45.     cin.tie(0);
  46.     solve();
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement