Submission #703219

#TimeUsernameProblemLanguageResultExecution timeMemory
703219rainboyModsum (NOI12_modsum)C11
25 / 25
1 ms292 KiB
#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 (stderr)

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...