Pagini recente » Cod sursa (job #2315110) | Cod sursa (job #86249) | Cod sursa (job #2028310) | Cod sursa (job #2515032) | Cod sursa (job #2494611)
#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";
}
else{
fout<<x*(c/d)<<" "<<y*(c/d)<<"\n";
}
}
return 0;
}