This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |