Pagini recente » Cod sursa (job #662596) | Cod sursa (job #1831412) | Cod sursa (job #1654343) | Cod sursa (job #1761108) | Cod sursa (job #2590377)
#include <iostream>
#include <fstream>
using namespace std;
struct str{
int d;
int x0;
int y0;
};
str euclid(int a, int b){
if(b==0)
return {a, 1, 0};
str d=euclid(b, a%b);
return {d.d, d.y0, d.x0-(a/b) * d.y0};
}
ifstream f("euclid3.in");
ofstream g("euclid3.out");
int main()
{
int t,a,b,c;
f>>t;
for(int i=1;i<=t;i++){
f>>a>>b>>c;
str e=euclid(a,b);
if(c % e.d==0)
g<<e.x0 * (c/e.d)<<" "<<e.y0 * (c/e.d)<<"\n";
else g<<0<<" "<<0<<"\n";
}
/*int a,b;
cin>>a>>b;
str e=euclid(a,b);
cout<<e.d<<" "<<e.x0<<" "<<e.y0;*/
return 0;
}