# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
949049 | rainboy | 분수 (KPI13_fractions) | C11 | 33 ms | 3012 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <stdio.h>
int main() {
int t;
scanf("%d", &t);
while (t--) {
int a, b, c, d, k, x1, y1, x2, y2;
scanf("%d%d%d%d", &a, &b, &c, &d);
x1 = 0, y1 = 1, x2 = 1, y2 = 0;
while (1)
if (a >= b) {
k = a / b;
a -= b * k, c -= d * k;
x1 += x2 * k, y1 += y2 * k;
} else if (c <= d) {
k = d / c;
b -= a * k, d -= c * k;
x2 += x1 * k, y2 += y1 * k;
} else
break;
printf("%d %d\n", x1 + x2, y1 + y2);
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |