这至少有20pts吧,
可是我wa4个,其他T了。
#include <bits/stdc++.h>
using namespace std;
typedef long long lli;
typedef pair<int, int> pii;
#define m_p make_pair
#define INF 2147483647
#define INFL 9223372036854775807LL
#define int long long
int gcd(int x, int y) {
if (y == 0) return x;
return gcd(y, x % y);
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
// freopen("math.in", "r", stdin);
// freopen("math.out", "w", stdout);
int t, x, z, tmp;
cin >> t;
while (t--) {
cin >> x >> z;
tmp = z / x;
bool f = false;
for (int y = 1; y <= tmp; y++) {
int g = gcd(x, y);
int r = y * g;
if (y * g == tmp) {
f = true;
cout << y;
break;
}
}
if (!f) cout << -1;
if (t) cout << endl;
}
return 0;
}