Pagini recente » Cod sursa (job #33111) | Cod sursa (job #3252255) | Cod sursa (job #2475379) | Cod sursa (job #1325680) | Cod sursa (job #2479704)
#include <fstream>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
const int MAX=1000000;
void euclid(int a,int b,int &x,int &y,int &d){
if(b==0){
d=a;
x=1;
y=0;
}
else{
int xc,yc;
euclid(b,a%b,xc,yc,d);
x=yc;
y=xc-(a/b)*yc;
}
}
using namespace std;
int main(){
ifstream in("euclid3.in");
ofstream out("euclid3.out");
int t;
in>>t;
while(t--){
int a,b,c,d,x,y;
x=1;
y=0;
in>>a>>b>>c;
euclid(a,b,x,y,d);
if(c%d!=0)
out<<0<<" "<<0<<"\n";
else
out<<x*(c/d)<<" "<<y*(c/d)<<"\n";
}
return 0;
}