Pagini recente » Monitorul de evaluare | Cod sursa (job #2929398) | Cod sursa (job #3032822) | Rating Mihai-Teodor Ailincai (mihaiailincai) | Cod sursa (job #2513198)
#include <bits/stdc++.h>
using namespace std;
int ii, n, a, b, c, d, x, y;
int gcd(int a, int b, int & x, int & y)
{
if(a == 0)
{
x = 0;
y = 1;
return b;
}
int x1, y1;
int d = gcd(b % a, a, x1, y1);
x = y1 - (b / a) * x1;
y = x1;
return d;
}
int main()
{
ifstream f("euclid3.in");
ofstream g("euclid3.out");
f >> n;
for(ii = 1; ii <= n; ii ++)
{
f >> a >> b >> d;
c = gcd(a, b, x, y);
if(d % c != 0)
{
g << "0 0" << "\n";
continue;
}
g <<(d / c) * x << " " << (d / c) * y << "\n";
}
return 0;
}