fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. typedef long long ll;
  4. const int Mod=998244353;
  5.  
  6. void solve() {
  7.  
  8. ll a,b;
  9. cin >> a >> b;
  10.  
  11. if(b%a==0){
  12. cout << b*b/a << '\n';
  13. return;
  14. }
  15.  
  16. cout << __gcd(a,b)/a*b << '\n';
  17. }
  18.  
  19. int main(){
  20. ios::sync_with_stdio(false);
  21. cin.tie(nullptr);
  22.  
  23. int t;
  24. cin >> t;
  25. while (t--) solve();
  26.  
  27.  
  28. return 0;
  29. }
  30.  
Success #stdin #stdout 0.01s 5320KB
stdin
8
2 3
1 2
3 11
1 5
5 10
4 6
3 9
250000000 500000000
stdout
0
4
0
25
20
0
27
1000000000