Cod sursa(job #2484809)
Utilizator | Data | 31 octombrie 2019 17:08:44 | |
---|---|---|---|
Problema | Algoritmul lui Euclid extins | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.6 kb |
#include <cstdio>
using namespace std;
long long x,y,d;
void eucl(long long a,long long b)
{
if(!b)
{
x=1;
y=0;
d=a;
return;
}
eucl(b,a%b);
int tmp=y;
y=x-(a/b)*y;
x=tmp;
}
int main()
{
freopen("euclid3.in","r",stdin);
freopen("euclid3.out","w",stdout);
long long t,a,b,c;
scanf("%lld",&t);
while(t--)
{
scanf("%lld%lld%lld",&a,&b,&c);
eucl(a,b);
if(c%d)
printf("0 0\n");
else
printf("%lld %lld\n",x*c/d,y*c/d);
}
return 0;
}