Submission #949049

#TimeUsernameProblemLanguageResultExecution timeMemory
949049rainboy분수 (KPI13_fractions)C11
1 / 1
33 ms3012 KiB
#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)

fractions.c: In function 'main':
fractions.c:6:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
    6 |  scanf("%d", &t);
      |  ^~~~~~~~~~~~~~~
fractions.c:10:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |   scanf("%d%d%d%d", &a, &b, &c, &d);
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...