Cod sursa(job #2520423)
| Utilizator | Data | 9 ianuarie 2020 13:45:54 | |
|---|---|---|---|
| Problema | Algoritmul lui Euclid extins | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.6 kb |
#include <fstream>
#define LL long long
using namespace std;
ifstream fin("euclid3.in");
ofstream fout("euclid3.out");
int T;
LL a,b,c,d,x,y;
void cmmdc(LL a,LL b,LL &d,LL &x,LL &y)
{
if(b==0)
{
x=1;
y=0;
d=a;
return;
}
else
cmmdc(b,a%b,d,x,y);
x=y;
y=(d-a*x)/b;
}
int main()
{
fin>>T;
while(T--)
{
LL x,y,d;
fin>>a>>b>>c;
cmmdc(a,b,d,x,y);
if(c%d)
fout<<"0"<<" "<<"0"<<"\n";
else
fout<<x*(c/d)<<" "<<y*(c/d)<<"\n";
}
return 0;
}
