View difference between Paste ID: tqXZ5eCQ and k6sfQM5P
SHOW: | | - or go back to the newest paste.
1
#include <stdlib.h>
2
#include <stdio.h>
3
4-
int MOD = 12582917;
4+
long MOD = 12582917;
5
6
int main()
7
{
8-
  int w, x, y, z;
8+
  long w, x, y, z;
9-
  int sum = 0; // sum of wxyz over w + x + y + z = 2011 % MOD
9+
  long sum = 0; // sum of wxyz over w + x + y + z = 2011 % MOD
10-
  int count = 0;
10+
  long count = 0;
11
  for(w = 0; w <= 2011; ++w) {
12
    for(x = 0; x <= 2011 - w; ++x) {
13
      for(y = 0; y <= 2011 - w - x; ++y) {
14
        z = 2011 - w - x - y;
15
        // printf("%d %d %d %d\n", w, x, y, z);
16
        sum = (sum + w * x * y * z) % MOD;
17
        ++count;
18
      }
19
    }
20
  }
21
22-
  printf("sum: %d, terms: %d\n", sum, count);
22+
  printf("sum: %ld, terms: %ld\n", sum, count);
23
  // should give (2014 choose 7) % MOD, (2014 choose 3)
24-
}
24+
}
25