Pagini recente » Cod sursa (job #102976) | Cod sursa (job #821256) | Cod sursa (job #1228319) | hlo_cj_av_l2 | Cod sursa (job #2487953)
// Euclid extins.cpp : Defines the entry point for the console application.
//
//#include "stdafx.h"
#include <fstream>
std::ifstream fin("euclid3.in");
std::ofstream fout("euclid3.out");
long long max(long long a, long long b) {
if (a > b)
return a;
else return b;
}
void euclid_extins(long long *x, long long *y, long long a, long long b, long long *d)
{
if (b == 0)
{
*x = 1;
*y = 0;
*d = a;
}
else {
long long x0, y0;
euclid_extins(&x0, &y0, b, a%b, d);
*x = y0;
*y = x0 - (a / b)* y0;
}
}
int main()
{
short T;
fin >> T;
long long a, b, c;
long long x = 0, y = 0;
for (int i = 0; i < T; i++) {
fin >> a >> b >> c;
long long d;
euclid_extins(&x, &y, a, b, &d);
if ( c % d == 0 )
fout << x * c/d << " " << y * c/d << std::endl;
else fout << 0 << " " << 0 << std::endl;
}
}