This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |