Advertisement
pb_jiang

CF1444A WA

Apr 17th, 2023
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.59 KB | None | 0 0
  1. // Problem: A. Division
  2. // Contest: Codeforces - Codeforces Round 680 (Div. 1, based on Moscow Team Olympiad)
  3. // URL: https://codeforces.com/problemset/problem/1444/A
  4. // Memory Limit: 512 MB
  5. // Time Limit: 1000 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. #define dbg(...) logger(#__VA_ARGS__, __VA_ARGS__)
  13. template <typename... Args> void logger(string vars, Args &&... values)
  14. {
  15.     cerr << vars << " = ";
  16.     string delim = "";
  17.     (..., (cerr << delim << values, delim = ", "));
  18.     cerr << endl;
  19. }
  20.  
  21. template <class T> inline auto vv(int m) { return vector<vector<T>>(m, vector<T>(m)); }
  22. template <class T> inline auto vv(int m, int n) { return vector<vector<T>>(m, vector<T>(n)); }
  23. template <class T, T init> inline auto vv(int m) { return vector<vector<T>>(m, vector<T>(m, init)); }
  24. template <class T, T init> inline auto vv(int m, int n) { return vector<vector<T>>(m, vector<T>(n, init)); }
  25.  
  26. template <class T> using mpq = priority_queue<T, vector<T>, greater<T>>;
  27.  
  28. using ll = long long;
  29. using pii = pair<int, int>;
  30. using vl = vector<ll>;
  31. using vi = vector<int>;
  32.  
  33. int main(int argc, char **argv)
  34. {
  35.     int t;
  36.     ll p, q;
  37.     cin >> t;
  38.     while (t--) {
  39.         cin >> p >> q;
  40.         if (p % q) {
  41.             cout << p << endl;
  42.         } else {
  43.             ll ans = 1;
  44.             for (ll i = 2; i * i <= q; ++i) {
  45.                 if (q % i == 0) {
  46.                     ans = max(ans, p / (q / i));
  47.                 }
  48.             }
  49.             cout << ans << endl;
  50.         }
  51.     }
  52.     return 0;
  53. };
  54.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement