Cod sursa(job #2221760)
| Utilizator | Data | 15 iulie 2018 19:33:26 | |
|---|---|---|---|
| Problema | Algoritmul lui Euclid extins | Scor | 70 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.71 kb |
#include <iostream>
#include <fstream>
using namespace std;
int cmmdc( int a, int b){
if(!b) return a;
return cmmdc(b,a%b);
}
int main()
{
int k,i,a,b,c;
ifstream in;
in.open("euclid3.in");
ofstream out;
out.open("euclid3.out");
in >> k;
for(i = 0 ;i != k; i++ ){
in >> a >> b >> c;
int cmm = cmmdc(a,b);
if (c % cmm != 0) out <<"0 0\n";
else{
a = a / cmm;
b = b / cmm;
c = c / cmm;
int x = 0,aux = c;
while(aux % b != 0){
x++;
aux -= a;
}
out <<x<<" "<<(c - x * a) / b<<endl;
}
}
return 0;
}
