Cod sursa(job #2870799)
Utilizator | Data | 12 martie 2022 16:11:29 | |
---|---|---|---|
Problema | Algoritmul lui Euclid extins | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.67 kb |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ifstream f("euclid3.in");
ofstream g("euclid3.out");
void gcd_extins(ll &d,ll a,ll b,ll &x,ll &y)
{
if (b==0)
{
x=1;
y=0;
d=a;
return;
}
ll x2,y2;
gcd_extins(d,b,a%b,x2,y2);
ll c= a/b;
x = y2;
y = x2 - c*y2;
}
ll t,a,b,c,d;
int main()
{
f>>t;
for (;t--;)
{
f>>a>>b>>c;
ll x,y;
gcd_extins(d,a,b,x,y);
if (c%d!=0)
{
g<<"0"<<" "<<"0"<<'\n';
}
else
{
g<<x*(c/d)<<" "<<y*(c/d)<<'\n';
}
}
return 0;
}