Submission #332436

#TimeUsernameProblemLanguageResultExecution timeMemory
332436guka415Modsum (NOI12_modsum)C++14
25 / 25
95 ms492 KiB
#define fast ios::sync_with_stdio(false); cin.tie(0); #define foru(i, k, n) for (int i = k; i < n; i++) #define ford(i, k, n) for (int i = k; i >= n; i--) #define pb push_back #include <iostream> #include <algorithm> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef long double ld; typedef pair<ll, ll> pll; const int sz = 1e6; ll crsm = 0, ret = 0; int n; int u[sz], v[sz]; void foo(int i) { if (i == n) { ret += ((crsm * crsm * crsm * crsm + 2 * crsm * crsm) % 5 + 1); return; } else { for (int val = u[i]; val <= v[i]; val++) { crsm += val; foo(i + 1); crsm -= val; } } } int main() { fast; cin >> n; foru(i, 0, n)cin >> u[i] >> v[i]; foo(0); cout << ret << '\n'; return 0; }
#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...