답안 #10366

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
10366 2014-10-20T01:44:56 Z gs14004 나머지들의 합 (NOI12_modsum) C++
25 / 25
0 ms 1116 KB
#include <cstdio>

int n,s[1005], e[1005];

int dp[5][1005];
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));
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1116 KB Output is correct
2 Correct 0 ms 1116 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1116 KB Output is correct
2 Correct 0 ms 1116 KB Output is correct
3 Correct 0 ms 1116 KB Output is correct
4 Correct 0 ms 1116 KB Output is correct
5 Correct 0 ms 1116 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1116 KB Output is correct
2 Correct 0 ms 1116 KB Output is correct
3 Correct 0 ms 1116 KB Output is correct
4 Correct 0 ms 1116 KB Output is correct
5 Correct 0 ms 1116 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1116 KB Output is correct
2 Correct 0 ms 1116 KB Output is correct
3 Correct 0 ms 1116 KB Output is correct
4 Correct 0 ms 1116 KB Output is correct
5 Correct 0 ms 1116 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1116 KB Output is correct
2 Correct 0 ms 1116 KB Output is correct
3 Correct 0 ms 1116 KB Output is correct
4 Correct 0 ms 1116 KB Output is correct
5 Correct 0 ms 1116 KB Output is correct