SHARE
TWEET

Untitled

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