Pagini recente » Cod sursa (job #1891822) | Borderou de evaluare (job #133079) | Cod sursa (job #1847394) | Cod sursa (job #2392063) | Cod sursa (job #3001422)
#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;
int t=1,a,b,c;
int gcd(int a,int b){
if(b==0)return a;
return gcd(b,a%b);
}
void euclid(int a,int b,int *d,int *x,int *y){
if(b==0){
*d=a;
*x=1;
*y=0;
}
else{
int 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;
int d=gcd(a,b);
if(c%d!=0){
cout<<"0 0"<<endl;
continue;
}
a=a;
b=b;
int x;
int y;
euclid(a,b,&d,&x,&y);
cout<<x*c/d<<" "<<y*c/d<<endl;
}
}