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 sum[1001][5];
int main() {
int n;
cin>>n;
sum[0][0]=1;
for (int i=1;i<=n;i++){
int a,b;
cin>>a>>b;
for (int j=a;j<=b;j++){
int c=j%5;
for (int k=0;k<5;k++){
sum[i][k]+=sum[i-1][(k+c)%5];
}
}
}
int ans=0;
for (int i=0;i<5;i++){
ans+=sum[n][i]*(((i*i*i*i+2*i*i)%5)+1);
}
cout<<ans;
}
# | 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... |