pb_jiang

CF1538D

Mar 28th, 2025
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.37 KB | None | 0 0
  1. // Problem: D. Another Problem About Dividing Numbers
  2. // Contest: Codeforces - Codeforces Round 725 (Div. 3)
  3. // URL: https://codeforces.com/problemset/problem/1538/D
  4. // Memory Limit: 256 MB
  5. // Time Limit: 2000 ms
  6. //
  7. // Powered by CP Editor (https://cpeditor.org)
  8.  
  9. #include <assert.h>
  10. #include <bits/stdc++.h>
  11. using namespace std;
  12. #ifndef __DEBUG__
  13. #define dbg(...) 42
  14. #endif
  15. template <class T> using mpq = priority_queue<T, vector<T>, greater<T>>;
  16.  
  17. using ll = long long;
  18. using a2l = array<ll, 2>;
  19. using pll = pair<ll, ll>;
  20. using vl = vector<ll>;
  21.  
  22. constexpr ll ub = 1e5 + 3;
  23. vl ps, np(ub), pf(ub);
  24.  
  25. void init()
  26. {
  27.     for (ll i = 2; i < ub; ++i) {
  28.         if (np[i] == 0) {
  29.             ps.push_back(i);
  30.             pf[i] = i;
  31.         }
  32.         for (auto x : ps) {
  33.             if (i * x >= ub)
  34.                 break;
  35.             np[i * x] = 1;
  36.             pf[i * x] = x;
  37.             if (i % x == 0)
  38.                 break;
  39.         }
  40.     }
  41. }
  42.  
  43. ll get_fcnt(ll v)
  44. {
  45.     ll ret = 0;
  46.     if (v > ub) {
  47.         for (auto x : ps) {
  48.             while (v % x == 0) {
  49.                 v /= x;
  50.                 ret += 1;
  51.             }
  52.         }
  53.         if (v > ub)
  54.             return ret + 1;
  55.     }
  56.     while (v != 1) {
  57.         v /= pf[v];
  58.         ret += 1;
  59.     }
  60.     return ret;
  61. };
  62.  
  63. void solve()
  64. {
  65.     ll a, b, k;
  66.     cin >> a >> b >> k;
  67.     ll g = gcd(a, b), l = lcm(a, b);
  68.     // ll min_op = a != b ? (a / g != 1) + (b / g != 1) : 0;
  69.     ll min_op = a == b ? 0 : (g == a || g == b ? 1 : 2);
  70.     ll max_op = get_fcnt(a) + get_fcnt(b);
  71.     // cout << (min_op <= k && k <= max_op ? "YES" : "NO") << '\n';
  72.     /*
  73.     if (min_op <= k && k <= max_op) {
  74.         if (k == 1 && min_op == 1) {
  75.             cout << "YES" << '\n';
  76.         } else if (k != 1) {
  77.             cout << "YES" << '\n';
  78.         } else {
  79.             cout << "NO" << '\n';
  80.         }
  81.     } else {
  82.         cout << "NO" << '\n';
  83.     }
  84.     */
  85.     dbg(min_op, k, max_op);
  86.     if (min_op <= k && k <= max_op) {
  87.         if (k != 1 || min_op == 1) {
  88.             cout << "YES" << '\n';
  89.         } else {
  90.             cout << "NO" << '\n';
  91.         }
  92.     } else {
  93.         cout << "NO" << '\n';
  94.     }
  95. }
  96.  
  97. int main(int argc, char **argv)
  98. {
  99.     std::ios::sync_with_stdio(false);
  100.     std::cin.tie(nullptr);
  101.  
  102.     ll t;
  103.     cin >> t;
  104.     init();
  105.     while (t--)
  106.         solve();
  107.     return 0;
  108. };
  109.  
Add Comment
Please, Sign In to add comment