Pagini recente » Cod sursa (job #470997) | Cod sursa (job #1026463) | Cod sursa (job #2211726) | Cod sursa (job #2448515) | Cod sursa (job #362831)
Cod sursa(job #362831)
#include <iostream>
#include <fstream>
using namespace std;
void euclid(long int a,long int b,long int & cmmdc,long int &x,long int &y){
if(b){
long int x0,y0;
euclid(b,a%b,cmmdc,x0,y0);
x=y0;
y=x0-(a/b)*y0;
}else{
cmmdc=a;
x=1;
y=0;
}
}
int main(){
ifstream in("euclid3.in");
ofstream out("euclid3.out");
int n;in>>n;
for(int i=0;i<n;i++){
long int a,b,c,x,y,cmmdc;
in>>a>>b>>c;
euclid(a,b,cmmdc,x,y);
if(c%cmmdc){
out<<"0 0\n";
}else{
out<<x*(c/cmmdc)<<" "<<y*(c/cmmdc)<<endl;
}
}
}