Pagini recente » Cod sursa (job #1207922) | Cod sursa (job #2506074) | Cod sursa (job #1794408) | Cod sursa (job #293148) | Cod sursa (job #2342255)
#include <iostream>
#include <fstream>
using namespace std;
int rec(int x, int y)
{
if((x == 0) || (y == 0))
{
return(0);
}
int r = x % y;
if(x % y != 0)
{
x = y;
y = r;
return(rec(x, y));
}
else
{
return(y);
}
}
int main()
{
ifstream infile("euclid3.in");
ofstream outfile("euclid3.out");
int a=0, b=0, c=0, x, y, t=0;
infile >> t;
if((t >= 1) && (t <= 100))
{
for(t; t>0; t--)
{
infile >> a >> b >> c;
if((-1000000000 <= a <= 1000000000) &&
(-1000000000 <= b <= 1000000000) &&
(-2000000000 <= c <= 2000000000) &&
(c != 0))
{
int count=1000000000, AsauF=0;
y = rec(a, b);
back:
if(--count <= 0){goto zero;}
x = (c - (b * y)) / a;
if((a * x) + (b * y) == c)
{
outfile << x << " " << y << endl;
AsauF=1;
goto final;
}
else
{
y++;
goto back;
}
zero:
if(AsauF == 0)
{
outfile << "0 0" << endl;
}
final: continue;
}
}
}
infile.close();
outfile.close();
return(0);
}