Pagini recente » Cod sursa (job #3180230) | Cod sursa (job #1526028) | Cod sursa (job #848888) | Cod sursa (job #2709839) | Cod sursa (job #2222288)
#include<iostream>
#include<fstream>
void euclid(int a, int b, int *d, int *x, int *y)
{
if (b == 0) {
*d = a;
*x = 1;
*y = 0;
}
else {
int x0, y0;
euclid(b, a % b, d, &x0, &y0);
*x = y0;
*y = x0 - (a / b) * y0;
}
}
using namespace std;
ifstream f("euclid3.in");
ofstream g("euclid3.out");
int main()
{
int a,b,t,c;
f>>t;
int d;
while(t--)
{
f>>a>>b>>c;
int x,y;
d=c;
euclid(a,b,&d,&x,&y);
g<<x<<" "<<y<<endl;
}
return 0;
}
/*
#include<iostream>
#include<string>
using namespace std;
int main()
{
int l;
string s;
cin>>l;
cin>>s;
cout<<s;
}
*/