SHARE
TWEET

Untitled

a guest Nov 13th, 2019 82 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <bits/stdc++.h>
  2.  
  3. #pragma GCC optimize("Ofast")
  4. using namespace std;
  5.  
  6. #define times(I, X) for (ll I=0; I<(X); I++)
  7. #define rtimes(I, X) for (ll I=(X)-1; I>=0; I--)
  8. #define all(X) (X).begin(), (X).end()
  9. #define rall(X) (X).rbegin(), (X).rend()
  10.  
  11. #ifdef DEBUG
  12.     #define dump(X) std::cout << __LINE__ << "L: [" << #X << "] = [" << X << "]" << endl
  13. #else
  14.     #define dump(X)
  15. #endif
  16.  
  17. using ll = int;
  18. using ull = unsigned long long;
  19.  
  20. ll mod = 1'000'000'007;
  21.  
  22. const int N = 1'000'000;
  23. int lp[N+1];
  24. vector<int> pr;
  25.  
  26. void prr(){
  27. for (int i=2; i<=N; ++i) {
  28.     if (lp[i] == 0) {
  29.         lp[i] = i;
  30.         pr.push_back (i);
  31.     }
  32.     for (int j=0; j<(int)pr.size() && pr[j]<=lp[i] && i*pr[j]<=N; ++j)
  33.         lp[i * pr[j]] = pr[j];
  34. }}
  35.  
  36. int main() {
  37.     ios_base::sync_with_stdio(false);
  38.  
  39.     prr();
  40.  
  41.     ll t;
  42.     cin >> t;
  43.  
  44.     times(_i, t) {
  45.         ll a, b;
  46.         cin >> a >> b;
  47.  
  48.         map<ll, ll> ma, mb;
  49.  
  50.         ll aa = a, bb = b;
  51.  
  52.         for (ll i: pr) {
  53.             while (aa % i == 0) {
  54.                 aa /= i;
  55.                 ma[i]++;
  56.             }
  57.  
  58.             if (aa == 1)
  59.                 break;
  60.         }
  61.  
  62.         if (aa != 1)
  63.             ma[aa]++;
  64.  
  65.         for (ll i: pr) {
  66.             while (bb % i == 0) {
  67.                 bb /= i;
  68.                 mb[i]++;
  69.             }
  70.  
  71.             if (bb == 1)
  72.                 break;
  73.         }
  74.  
  75.         if (bb != 1)
  76.             ma[bb]++;
  77.  
  78.         if (ma.size() != mb.size()) {
  79.             cout << "No" << endl;
  80.             goto net;
  81.         }
  82.  
  83.         for (auto [mn, clva]: ma) {
  84.             ll clvb = mb[mn];
  85.  
  86.             // dump(clva); dump(clvb); dump(mn); dump(2*clvb - clva);
  87.             if ((2*clvb - clva) % 3 == 0 && (2*clvb - clva) >= 0) {} else {
  88.                 cout << "No" << endl;
  89.                 goto net;
  90.             }
  91.         }
  92.  
  93.         cout << "Yes" << endl;
  94.         net:;
  95.     }
  96.  
  97.     return 0;
  98. }
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