Cod sursa(job #1204862)
| Utilizator | Data | 4 iulie 2014 11:47:11 | |
|---|---|---|---|
| Problema | Algoritmul lui Euclid extins | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.65 kb |
#include <fstream>
using namespace std;
ifstream fin("euclid3.in");
ofstream fout("euclid3.out");
int t;
int Bomb(int a,int b, int &x, int &y) {
if (b == 0) {
x = 1;
y = 0;
return a;
}
int xx, yy;
int d = Bomb(b, a % b, xx, yy);
x = yy;
y = xx - (a / b) * yy;
return d;
}
int main() {
int a,b,c,x,y,d,i;
fin >> t;
while(t--){
fin >> a >> b >> c;
d = Bomb(a, b, x, y);
if (c % d)
fout << "0 0\n";
else
fout << x * (c / d) << " " << y * (c / d) << "\n";
}
fin.close();
fout.close();
return 0;
}
