Cod sursa(job #2336079)
| Utilizator | Data | 4 februarie 2019 19:33:58 | |
|---|---|---|---|
| Problema | Algoritmul lui Euclid extins | Scor | 0 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.59 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream f("euclid3.in");
ofstream g("euclid3.out");
long N,a,b,c,d;
long long x,y,x0,y0;
void Euclid(long a,long b)
{
if(b==0)
{
x=1;
y=0;
d=a;
return;
}
else
{
Euclid(b,a%b);
x0=x;
y0=y;
x=y0;
y=x0-(a/b)*y0;
}
}
int main()
{
f>>N;
for(int i=1;i<=N;i++)
{
f>>a>>b>>c;
Euclid(a,b);
if(c%d) g<<0<<" "<<0<<'\n';
else
g<<x*(c/d)<<" "<<y*(c/d)<<'\n';
}
return 0;
}
