Pagini recente » Cod sursa (job #1483030) | Cod sursa (job #1193964) | Cod sursa (job #2483504) | Cod sursa (job #2896411) | Cod sursa (job #997791)
Cod sursa(job #997791)
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <fstream>
using namespace std;
const string file = "euclid3";
const string infile = file + ".in";
const string outfile = file + ".out";
const int INF = 0x3f3f3f3f;
int euclid(int a, int b, int& x, int& y)
{
if(b == 0)
{
x = 1;
y = 0;
return a;
}
else
{
int x0 = 0;
int y0 = 0;
int d = euclid(b, a % b, x0, y0);
x = y0;
y = x0 - (a/b) * y0;
return d;
}
}
int main()
{
fstream fout(outfile.c_str(), ios::out);
fstream fin(infile.c_str(), ios::in);
int T;
fin >> T;
for(int i = 0; i < T; i++)
{
int a, b, c;
fin >> a >> b >> c;
int x, y;
int d = euclid(a, b, x, y);
if(c % d != 0)
{
fout << 0 << " " << 0 << "\n";
}
else
{
fout << x * (c/d) << " " << y * (c/d) << "\n";
}
}
fin.close();
fout.close();
}