Submission #703219

# Submission time Handle Problem Language Result Execution time Memory
703219 2023-02-26T15:12:44 Z rainboy Modsum (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);
      |   ^~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory 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
# Verdict Execution time Memory 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
# Verdict Execution time Memory 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
# Verdict Execution time Memory 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