Pagini recente » Cod sursa (job #1490586) | Cod sursa (job #3329466) | Cod sursa (job #3357510) | Cod sursa (job #3304433) | Cod sursa (job #3356718)
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("euclid3.in");
ofstream fout("euclid3.out");
int main(){
long long y0 = 0, y1 = 1;
long long x0 = 1, x1 = 0;
long long a, b, c, d;
long long r, q, y, x;
int t;
fin >> t;
for(int i = 0; i < t; i++){
fin >> a >> b >> c;
while (b != 0)
{
r = a % b;
q = a / b;
a = b;
b = r;
x = x0 - q * x1;
y = y0 - q * y1;
y0 = y1; x0 = x1;
y1 = y; x1 = x;
cout << a << " " << b << " ";
cout << q << " " << r << " ";
cout << y1 << " " << y0 << endl;
}
d = a;
if(c % d == 0){
fout << x0 << " " << y0<< endl;
}
else{
fout << 0 << " " << 0 << endl;
}
}
fin.close();
fout.close();
return 0;
}