Pagini recente » Cod sursa (job #1260994) | Cod sursa (job #1797967) | Clasament Summer Challenge 2009, Runda 2 | Cod sursa (job #1982613) | Cod sursa (job #3001424)
#include <bits/stdc++.h>
using ll=long long;
#define S second
#define F first
#define endl '\n'
#define spid ios_base::sync_with_stdio(false);cin.tie(NULL);
const int mod=1e9+7;
const double pi=3.14159265359;
const int maxn=200001;
using namespace std;
ll t=1,a,b,c;
int gcd(ll a,ll b){
if(b==0)return a;
return gcd(b,a%b);
}
void euclid(ll a,ll b,ll *d,ll *x,ll *y){
if(b==0){
*d=a;
*x=1;
*y=0;
}
else{
ll x0,y0;
euclid(b,a%b,d,&x0,&y0);
*x=y0;
*y=x0-(a/b)*y0;
}
}
int main(){
ifstream cin("euclid3.in");
ofstream cout("euclid3.out");
cin>>t;
while(t--){
cin>>a>>b>>c;
ll d=gcd(a,b);
if(c%d!=0){
cout<<"0 0"<<endl;
continue;
}
a=a;
b=b;
ll x;
ll y;
euclid(a,b,&d,&x,&y);
cout<<x*c/d<<" "<<y*c/d<<endl;
}
}