Cod sursa(job #3357402)
| Utilizator | Data | 9 iunie 2026 12:39:16 | |
|---|---|---|---|
| Problema | Algoritmul lui Euclid extins | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.69 kb |
#include <fstream>
using namespace std;
ifstream fin("euclid3.in");
ofstream fout("euclid3.out");
void euclid(int a, int b, long long &d, long long &x, long long &y)
{
if (b == 0) {
d = a;
x = 1;
y = 0;
} else {
long long x0, y0;
euclid(b, a % b, d, x0, y0);
x = y0;
y = x0 - (a / b) * y0;
}
}
int main()
{
int t,a,b,c;
fin>>t;
for(int i=1;i<=t;i++){
fin>>a>>b>>c;
long long d,x,y;
euclid(a,b,d,x,y);
if(c%d == 0){
fout<<x*c/d<< " "<<y*c/d<< '\n';
}
else{
fout<<0<< " "<<0<< '\n';
}
}
return 0;
}
