Submission #734062

# Submission time Handle Problem Language Result Execution time Memory
734062 2023-05-01T15:29:38 Z Amaarsaa Modsum (NOI12_modsum) C++14
25 / 25
630 ms 308 KB
#include<bits/stdc++.h>

using namespace std;
using ll = long long;
ll n, ans, p, j, s;
ll l[1002], rn[1002], r[1002];
int main() {
	ll i;
	cin >> n;
	s = 1;
	for ( i = 1; i <= n; i ++) {
		cin >> l[i] >> r[i];
	}
	rn[n + 1] = 1;
	for ( i = n; i >= 1; i --) {
		rn[i] = rn[i + 1] * (r[i] - l[i] + 1);
	}
	s = 0;
	for ( i = 0; i < rn[1]; i ++) {
		ans = 0;
		p = i;
		for ( j = 1; j <= n; j++) {
			ans += l[j] + (p / rn[j + 1]);
			ans %= 5;
			p %= rn[j + 1]; 
		}
		ll R = pow (ans, 4) + 2 * pow(ans, 2);
		R %= 5;
		R ++;
		s += R;
	}
	cout << s << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 300 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 308 KB Output is correct
2 Correct 1 ms 308 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 6 ms 308 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 304 KB Output is correct
5 Correct 18 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 17 ms 212 KB Output is correct
4 Correct 3 ms 212 KB Output is correct
5 Correct 60 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 41 ms 212 KB Output is correct
2 Correct 2 ms 212 KB Output is correct
3 Correct 630 ms 308 KB Output is correct
4 Correct 2 ms 212 KB Output is correct
5 Correct 321 ms 304 KB Output is correct