Cod sursa(job #2558602)
| Utilizator | Data | 26 februarie 2020 17:57:06 | |
|---|---|---|---|
| Problema | Algoritmul lui Euclid extins | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.69 kb |
#include <iostream>
#include <fstream>
using namespace std;
typedef long long ll;
void EuclidExtins(ll a,ll b,ll& d,ll& x,ll& y)
{
if(b==0)
{
x=1;
y=0;
d=a;
}
else
{
ll x0,y0;
EuclidExtins(b,a%b,d,x0,y0);
x=y0;
y=x0 - (a/b) * y0;
}
}
int main()
{
ifstream f("euclid3.in");
ofstream g("euclid3.out");
ll T,a,b,c,x,y,d;
f>>T;
for(int test=1;test<=T;test++)
{
f>>a>>b>>c;
EuclidExtins(a,b,d,x,y);
if(c%d)
g<<"0 0\n";
else
g<<x * (c/d)<<' '<<y * (c/d)<<'\n';
}
f.close();
g.close();
return 0;
}
