Pagini recente » Monitorul de evaluare | Cod sursa (job #1723561) | Cod sursa (job #3309832) | Cod sursa (job #2423642) | Cod sursa (job #3329127)
/// circular
#include <bits/stdc++.h>
using namespace std;
ifstream fin("euclid3.in");
ofstream fout("euclid3.out");
int n, i, v, c, g, rax, ray,nr;
void cmmdcplus(int a, int b, int &d, int &x, int &y)
{
if (b == 0)
{
d = a;
x = 1;
y = 0;
}
else
{
int x0, y0;
cmmdcplus(b, a % b, d, x0, y0);
x = y0;
y = x0 - (a / b) * y0;
}
}
int main()
{
fin >> n;
for (i = 1; i <= n; i++)
{
fin >> v >> c >> nr; // here
cmmdcplus(v, c, g, rax, ray);
if(nr%g==0)
fout << rax*(nr/g) << " " << ray*(nr/g) << '\n';
else
fout<<0<<" "<<0<<'\n';
}
return 0;
}