Submission #331699

# Submission time Handle Problem Language Result Execution time Memory
331699 2020-11-29T15:54:10 Z ncduy0303 Modsum (NOI12_modsum) C++17
25 / 25
247 ms 492 KB
#include <bits/stdc++.h>

using namespace std;

#define ar array
#define ll long long

const int MAX_N = 1e3 + 1;
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll LINF = 1e18;

int n, ans, l[MAX_N], r[MAX_N];

void f(int idx, ll sum) {
    if (idx == n) ans += (sum*sum*sum*sum + 2*sum*sum) % 5 + 1;
    for (int x = l[idx]; x <= r[idx]; x++) f(idx + 1, sum + x);
}

void solve() {
    cin >> n;
    for (int i = 0; i < n; i++) cin >> l[i] >> r[i];
    f(0, 0);
    cout << ans << "\n";
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

    int tc; tc = 1;
    for (int t = 1; t <= tc; t++) {
        // cout << "Case #" << t  << ": ";
        solve();
    }
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 236 ms 492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 2 ms 364 KB Output is correct
5 Correct 152 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 76 ms 492 KB Output is correct
4 Correct 9 ms 364 KB Output is correct
5 Correct 247 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 23 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 72 ms 492 KB Output is correct