Cod sursa(job #2180842)
| Utilizator | Data | 21 martie 2018 11:22:14 | |
|---|---|---|---|
| Problema | Algoritmul lui Euclid extins | Scor | 0 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.65 kb |
#include <fstream>
#include <bitset>
using namespace std;
ifstream fin("euclid3.in");
ofstream fout("euclid3.out");
long long a, b, c, d, x, y,t;
long long euclid(long long a, long long b, long long &x, long long &y)
{
if(b==0)
{
x=1;
y=0;
return a;
}
else
{
long long d,xa,ya;
d=euclid(b, a%b, xa, ya);
x=ya;
y=xa-a/b*ya;
return d;
}
}
int main()
{
fin>>t;
for(;t>0;t--)
{
fin>>a>>b>>c;
d=euclid(a, b, x, y);
fout<<x*(c/d)<<" "<<y*(c/d)<<"\n";
}
fin.close();
fout.close();
return 0;
}
