Submission #734062

#TimeUsernameProblemLanguageResultExecution timeMemory
734062AmaarsaaModsum (NOI12_modsum)C++14
25 / 25
630 ms308 KiB
#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 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...