Submission #331694

#TimeUsernameProblemLanguageResultExecution timeMemory
331694ncduy0303Modsum (NOI12_modsum)C++17
5 / 25
6 ms384 KiB
#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, l[MAX_N], r[MAX_N]; int f(int idx, int sum) { if (idx == n) return (sum*sum*sum*sum + 2*sum*sum) % 5 + 1; int res = 0; for (int x = l[idx]; x <= r[idx]; x++) { res += f(idx + 1, sum + x); } return res; } void solve() { cin >> n; for (int i = 0; i < n; i++) cin >> l[i] >> r[i]; cout << f(0, 0) << "\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 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...