题目描述 There are t queries. In each query, you are given two positive integers$a$ and $b$$(a, b\leq2×10^6)$ Please print a line consists of four positive integers $c,d,e,f$satisfying the following constraints:
$\frac{c}{d}-\frac{e}{f}=\frac{a}{b}$
$d < b$ and $f < b$
$1\leq c, e \leq4×10^{12}$
If there are multiple solutions, you can print anyone.
If there are no solution, please print “-1 -1 -1 -1” in this line.
输入描述 The first line contains one integer $t$ $(1\leq t\leq 10^5)$ — the number of test cases.
The only line of each test case contains two integers $a$ and $b$$(a, b\leq2×10^6)$
输出描述
For each test case print four integers — $c,d,e,f$. If there are no solution, $c,d,e,f$ should all be $-1$.
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll ex_gcd(ll a, ll b, ll &x, ll &y) { ll res, t; if(!b) { x = 1; y = 0; return a; } res = ex_gcd(b, a % b, x, y); t = x; x = y; y = t - (a / b) * y; return res; }
ll solve_ex_gcd(ll a, ll b, ll c, ll &x, ll &y) { ll inv = ex_gcd(a, b, x, y); if(c % inv) { x = -1; y = -1; return-1; } x *= (c / inv); y *= (c / inv); return0; }
voidsolve() { ll a, b; cin >> a >> b; ll k = gcd(a, b); if(k != 1) { a /= k; b /= k; cout << a + 1 << " " << b << " " << 1 << " " << b << endl; return ; } if(b == 1 is_prime[b]) cout << "-1 -1 -1 -1" << endl; else { ll tmp = 0, time = 0; ll bb = b; for(int i = 1;i <= p && bb != 1; i++) // 找两个素因数 { if(bb % prime[i] == 0) { tmp = prime[i]; while(bb % prime[i] == 0) { time++; bb /= prime[i]; } break; } } if(bb == 1) { cout << "-1 -1 -1 -1" << endl; return ; } ll d = 1; for(int i = 1;i <= time; i++) { d *= tmp; // b的一个因数 } ll f = bb; // b的另一个因数 ll c = 0, e = 0; solve_ex_gcd(f, d, a, c, e); if(c < 0 && e > 0) { cout << e << " " << f << " " << -c << " " << d << endl; } else cout << c << " " << d << " " << -e << " " << f << endl; } }