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>
int n,s[1005], e[1005];
int dp[1005][5];
int get_cnt(int x, int y){
if(y == n){
x=x*x+1;
return (x*x+4)%5+1;
}
if(dp[x][y]) return dp[x][y];
else{
int res = 0;
for (int i=s[y]; i<=e[y]; i++) {
res += get_cnt((x+i)%5,y+1);
}
return dp[x][y] =res;
}
}
int main(){
scanf("%d",&n);
for (int i=0; i<n; i++) {
scanf("%d %d",&s[i],&e[i]);
}
printf("%d",get_cnt(0,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... |