답안 #479384

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
479384 2021-10-11T14:39:48 Z rainboy Lun (COCI19_lun) C
50 / 50
1 ms 280 KB
#include <stdio.h>

#define N	100

int f(int d) {
	return d < 5 ? d * 2 : (d - 5) * 2 + 1;
}

int g(int d) {
	return d % 2 == 0 ? d / 2 : d / 2 + 5;
}

int main() {
	static char cc[N + 1];
	int n, i, i_, d;

	scanf("%d%s", &n, cc);
	d = 0, i_ = -1;
	for (i = n - 1; i >= 0; i--)
		if (cc[i] != 'x')
			d = (d + ((n - i) % 2 == 0 ? f(cc[i] - '0') : cc[i] - '0')) % 10;
		else
			i_ = i;
	d = (10 - d) % 10;
	if ((n - i_) % 2 == 0)
		d = g(d);
	printf("%d\n", d);
	return 0;
}

Compilation message

lun.c: In function 'main':
lun.c:17:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |  scanf("%d%s", &n, cc);
      |  ^~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 280 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 272 KB Output is correct
9 Correct 0 ms 280 KB Output is correct
10 Correct 0 ms 272 KB Output is correct