# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
750047 | sumit_kk10 | Modsum (NOI12_modsum) | C11 | 0 ms | 0 KiB |
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 <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;
}