Pagini recente » Cod sursa (job #100138) | Cod sursa (job #182526) | Cod sursa (job #2701721) | Cod sursa (job #134278) | Cod sursa (job #2867441)
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define dbg(x) cout << #x <<": " << x << "\n";
using ll = long long;
class InP {
FILE *fin;
char *buff;
int sp;
public:
InP(const char *p) {
fin = fopen(p, "r");
buff = new char[4096]();
sp = 4095;
}
char read_ch() {
sp++;
if (sp == 4096) {
fread(buff, 1, 4096, fin);
sp = 0;
}
return buff[sp];
}
InP &operator >>(int &n) {
char c;
int sgn = 1;
while (!isdigit(c = read_ch()) && c != '-');
if (c == '-') {
n = 0;
sgn = -1;
}
else n = c - '0';
while (isdigit(c = read_ch()))
n = n * 10 + c - '0';
n = n * sgn;
return *this;
}
InP &operator >>(ll &n) {
char c;
int sgn = 1;
while (!isdigit(c = read_ch()) && c != '-');
if (c == '-') {
n = 0;
sgn = -1;
}
else n = c - '0';
while (isdigit(c = read_ch()))
n = n * 10LL + c - '0';
n = n * sgn;
return *this;
}
InP &operator >> (char &n) {
n = read_ch();
// while ((n = read_ch()) != '\n' && n != ' ');
return *this;
}
};
class OuP {
FILE *fout;
char *buff;
int sp;
public:
OuP(const char *p) {
fout = fopen(p, "w");
buff = new char[50000];
sp = 0;
}
~OuP() {
fwrite(buff, 1, sp, fout);
fclose(fout);
}
void write_ch(char c) {
if (sp == 50000) {
fwrite(buff, 1, sp, fout);
sp = 0;
}
buff[sp++] = c;
}
OuP &operator <<(int n) {
if (n <= 9)
write_ch(n + '0');
else {
*(this) << (n / 10);
write_ch(n % 10 + '0');
}
return *this;
}
OuP &operator <<(ll n) {
if (n <= 9)
write_ch(n + '0');
else {
*(this) << (n / 10);
write_ch(n % 10 + '0');
}
return *this;
}
OuP &operator <<(char c) {
write_ch(c);
return *this;
}
OuP &operator <<(const char *c) {
while (*c) {
write_ch(*c);
c++;
}
return *this;
}
};
// InP fin("file.in");
// OuP fout("file.out");
ifstream fin("euclid3.in");
ofstream fout("euclid3.out");
int t;
int a, b, c;
int e(int a, int b, int &x, int &y) {
if (b == 0) {
x = 1;
y = 0;
return a;
}
int x0, y0;
int d = e(b, a % b, x0, y0);
x = y0;
y = x0 - (a / b) * y0;
return d;
}
int main() {
fin >> t;
while (t--) {
fin >> a >> b >> c;
int x, y;
int d = e(a, b, x, y);
if (c % d)
fout << "0 0\n";
else fout << x * (c / d) << " " << y * (c / d) << '\n';
}
// fin.close();
// fout.close();
return 0;
}