Submission #26799

#TimeUsernameProblemLanguageResultExecution timeMemory
26799sutekineModsum (NOI12_modsum)C++11
0 / 25
0 ms2228 KiB
#include <cstdio> #include <algorithm> #include <iostream> #include <queue> #include <vector> #include <map> #define oo 987654321 using namespace std; int n, s[1010], e[1010], dt[1010][10], ans; int main() { ios::sync_with_stdio(false); cin>>n; for(int i = 1 ; i <= n ; i++ ) cin>>s[i]>>e[i], ans += e[i]-s[i]+1; for(int i = 1 ; i <= n ; i++ ) for(int j = s[i] ; j <= e[i] ; j++ ) { if( i == 1 ) dt[i][j%5] += 1; else { for(int k = 0 ; k < 5 ; k++ ) dt[i][k] += dt[i-1][(5+(k-(j%5)))%5]; } } for(int i = 0 ; i < 5 ; i++ ) ans += ((2*(i*i)+(i*i*i*i))%5)*dt[n][i]; cout<<ans<<endl; 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...