답안 #750051

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
750051 2023-05-29T05:43:25 Z kalamazoo 나머지들의 합 (NOI12_modsum) C++14
25 / 25
101 ms 352 KB
#include <stdio.h>
#include <math.h>
 
int computeSum(int currentSum, int currentIndex, int n, int v[], int w[]) {
    if (currentIndex == n) {
        return (((int)(pow(currentSum,4)) + 2*(int)(pow(currentSum,2))) % 5 )+ 1;
    }
 
    int tempSum = 0;
    for (int i = v[currentIndex]; i <= w[currentIndex]; i++) {
        tempSum += computeSum((currentSum + i) % 5, currentIndex + 1, n, v, w);
    }
 
    return tempSum;
}
 
int main() {
    int n;
    scanf("%d", &n);
 
    int v[n], w[n];
    for (int i = 0; i < n; i++) {
        scanf("%d %d", &v[i], &w[i]);
    }
 
    int sum = computeSum(0, 0, n, v, w);
    printf("%d\n", sum);
 
    return 0;
}

Compilation message

modsum.cpp: In function 'int main()':
modsum.cpp:19:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
modsum.cpp:23:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |         scanf("%d %d", &v[i], &w[i]);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 3 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 4 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 4 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 10 ms 292 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 340 KB Output is correct
2 Correct 2 ms 352 KB Output is correct
3 Correct 38 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 101 ms 344 KB Output is correct