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 <bits/stdc++.h>
using namespace std;
int main()
{
int n;
vector<pair<int,int>>v;
cin>>n;
for(int i=0;i<n;i++)
{
int x,y;
cin>>x>>y;
v.push_back({x,y});
}
int dp[n][5];
memset(dp,0,sizeof dp);
for(int i=v[0].first;i<=v[0].second;i++)
{
dp[0][i%5]++;
}
for(int i=1;i<n;i++)
{
for(int mod=0;mod<5;mod++)
{
for(int j=v[i].first;j<=v[i].second;j++)
{
dp[i][(mod+j)%5]+=dp[i-1][mod];
}
}
}
/*for(int i=0;i<n;i++)
{
for(int mod=0;mod<5;mod++)
{
cout<<dp[i][mod]<<" ";
}
cout<<endl;
}*/
cout<<4*(dp[n-1][1]+dp[n-1][4])+5*(dp[n-1][2]+dp[n-1][3])+dp[n-1][0]<<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... |