Pagini recente » Cod sursa (job #559277) | Monitorul de evaluare | Cod sursa (job #2857980)
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define pi pair<ll, ll>
#define sz(x) (int)((x).size())
#define all(a) (a).begin(), (a).end()
/* int f[maxn],nf[maxn],inv[maxn];
const int M=998244353;
void init(){
inv[1]=1; for (int i=2;i<maxn;i++) inv[i]=M-1ll*(M/i)*inv[M%i]%M;
f[0]=nf[0]=1; for (int i=1;i<maxn;i++) f[i]=1ll*f[i-1]*i%M,nf[i]=1ll*nf[i-1]*inv[i]%M;
}
int C(int x,int y){return 1ll*f[x]*nf[y]%M*nf[x-y]%M;}*/
const ll mod = 1e9+7;
ll n, k, m, mi, ma;
pi euext(ll x, ll y){
if(x == 0) return mp(0, 1);
pi r = euext(y%x, x);
ll a = r.s - r.f*(y/x); ll b = r.f;
// ay%x + bx + a*x*y/x - a*y/x = 1, a*y + (b - a*y/x)x = 1
return mp(a, b);
}
void solve(){
ifstream cin("euclid3.in");
ofstream cout("euclid3.out");
ll t;
cin >> t;
while(t--){
ll a, b, c;
cin >> a >> b >> c;
pi r = euext(abs(a), abs(b));
ll x = abs(a)*r.f + abs(b)*r.s;
if(abs(c)%x){
cout << "0 0";
continue;
}
r.f *= c/x; r.s *= c/x;
if(a < 0) r.f *= -1;
if(b < 0) r.s *= -1;
cout << r.f << " " << r.s << "\n";
}
}
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
int t=1;
//cin >> t;
while(t--) solve();
return 0;
}