Pagini recente » Cod sursa (job #275037) | Cod sursa (job #902924) | Cod sursa (job #1086131) | Cod sursa (job #420923) | Cod sursa (job #2635002)
#include <bits/stdc++.h>
using namespace std;
long long Euclid_iter(long long a, long long b)
{
while(b!=0)
{
long long t;
t = a % b;
a = b;
b = t;
}
return a;
}
void Eulid_extins(long long a, long long b, long long c, double *x, double *y)
{
long long d=Euclid_iter(a,b);
cout<<d;
if(c%d)
{
*x=0;
*y=0;
return;
}
if(a==0)
{
*y=(double)c/b;
if(*y==(long long)*y)
*x=1;
else
{
*x=0;
*y=0;
}
return;
}
if(b==0)
{
*x=(double)c/a;
if(*x==(long long)*x)
*y=1;
else
{
*x=0;
*y=0;
}
return;
}
for(long long i=b; i < 2000000000; i+=b)
{
*x = (double)(d-i)/a * c/d;
cout<<*x<<endl;
if(*x==(long long)*x)
break;
}
*y = (c-a*(*x))/b;
}
int main()
{
fstream f("euclid3.in");
ofstream g("euclid3.out");
long long n, a, b, c;
double x, y;
f>>n;
for(long long i = 0; i < n; i++)
{
f>>a>>b>>c;
Eulid_extins(a, b, c, &x, &y);
g<<(long long)x<<' '<<(long long)y<<'\n';
}
f.close();
g.close();
return 0;
return 0;
}