제출 #949049

#제출 시각아이디문제언어결과실행 시간메모리
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;
}

컴파일 시 표준 에러 (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...