Cod sursa(job #2634299)
| Utilizator | Data | 10 iulie 2020 13:51:38 | |
|---|---|---|---|
| Problema | Algoritmul lui Euclid extins | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.61 kb |
#include <fstream>
std::ifstream in ("euclid3.in"); std::ofstream out ("euclid3.out");
void extins(int a, int b, int &x, int &y, int &d){
if(!b){
d = a;
x = 1;
y = 0;
}
else {
int x1,y1;
extins(b,a%b,x1,y1,d);
x = y1;
y = (x1-y1*(a/b));
}
}
int main(){
std::ios::sync_with_stdio(false);
int T;
in>>T;
int a,b,c,x,y,d;
while(T--){
in>>a>>b>>c;
extins(a,b,x,y,d);
if(c%d) out<<0<<" "<<0<<'\n';
else out<< x*(c/d)<<" "<<y*(c/d)<<'\n';
}
} 