This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#line 1 "MODSUM.cpp"
#include <bits/stdc++.h>
constexpr int K = 5;
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int n;
std::cin >> n;
std::vector<int> v(n), w(n);
for (int i = 0; i < 2 * n; i++) {
auto k = i / 2;
std::cin >> (i % 2 ? w[k] : v[k]);
}
std::array<int, K> cnt{};
cnt[0] = 1;
for (int i = 0; i < n; i++) {
std::array<int, K> cur{};
for (int j = v[i]; j <= w[i]; j++) {
for (int k = 0; k < K; k++) {
cur[(j + k) % K] += cnt[k];
}
}
cnt = std::move(cur);
}
std::int64_t ans = 0;
for (int i = 0; i < K; i++) {
std::int64_t v =
static_cast<std::int64_t>(std::pow(i, 4)) + 2 * std::pow(i, 2);
ans += cnt[i] * (v % K + 1);
}
std::cout << ans << "\n";
return 0;
}
# | 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... |