Pagini recente » Cod sursa (job #2373496) | Cod sursa (job #3195560) | Cod sursa (job #2678700) | Cod sursa (job #1463401) | Cod sursa (job #3170855)
#include <bits/stdc++.h>
using namespace std;
ifstream fin("euclid3.in");
ofstream fout("euclid3.out");
long long cmmdc(long long a, long long b){
if(b==0){
return a;
}
cmmdc(b,a%b);
}
void algoritmul_lui_euclid_extins(long long a,long long b,long long& x, long long& y){
if(b==0){
x=1;
y=0;
}
else{
long long x1,y1;
algoritmul_lui_euclid_extins(b,a%b,x1,y1);
//fout<<y1<<" "<<x1<<endl;
x=y1;
y=x1-(a/b)*y1;
}
}
long long n,a,b,c,d,xA,yA;
int main()
{
fin>>n;
for(int i=1;i<=n;i++){
fin>>a>>b>>c;
d=cmmdc(a,b);
if(c%d==0){
algoritmul_lui_euclid_extins(a,b,xA,yA);
fout<<xA*(c/d)<<" "<<yA*(c/d)<<endl;
}
else
fout<<"0 0"<<endl;
}
return 0;
}