답안 #703219

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
703219 2023-02-26T15:12:44 Z rainboy 나머지들의 합 (NOI12_modsum) C
25 / 25
1 ms 292 KB
#include <stdio.h>
#include <string.h>

#define M	5

int main() {
	static int dp[M], dq[M];
	int n, a, b, c, ans;

	scanf("%d", &n);
	dp[0] = 1;
	while (n--) {
		int l, r;

		scanf("%d%d", &l, &r);
		memset(dq, 0, M * sizeof *dq);
		for (a = 0; a < M; a++)
			for (b = 0; b < M; b++) {
				c = (a + b) % M;
				dq[c] += dp[a] * ((r + M - b) / M - (l - 1 + M - b) / M);
			}
		memcpy(dp, dq, M * sizeof *dq);
	}
	ans = 0;
	for (a = 0; a < M; a++)
		ans += dp[a] * ((a * a * a * a + a * a * 2) % M + 1);
	printf("%d\n", ans);
	return 0;
}

Compilation message

modsum.c: In function 'main':
modsum.c:10:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |  scanf("%d", &n);
      |  ^~~~~~~~~~~~~~~
modsum.c:15:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |   scanf("%d%d", &l, &r);
      |   ^~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 284 KB Output is correct
3 Correct 0 ms 288 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 284 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 292 KB Output is correct
4 Correct 0 ms 288 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 288 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 288 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct