Pagini recente » Cod sursa (job #1921729) | Cod sursa (job #1996280) | Cod sursa (job #611996) | Cod sursa (job #1589084) | Cod sursa (job #2494604)
#include <bits/stdc++.h>
using namespace std;
ifstream fin("euclid3.in");
ofstream fout("euclid3.out");
void gcdextended(long long a, long long b, long long &d, long long &x, long long &y)
{
if(b==0){
x=1, y=0;
d=a;
}
else{
long long x1, y1;
gcdextended(b, a%b, d, x1, y1);
x=y1;
y=x1-(a/b)*y1;
}
}
int main(){
long long a, b, c, n;
fin>>n;
while(n--){
fin>>a>>b>>c;
long long x=0, y=0, d=0;
gcdextended(a, b, d, x, y);
if(c%d){
fout<<0<<" "<<0<<"\n";
return 0;
}
else{
fout<<x*(c/d)<<" "<<y*(c/d)<<"\n";
return 0;
}
}
return 0;
}