Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdlib.h>
- #include <stdio.h>
- long MOD = 12582917;
- int main()
- {
- long w, x, y, z;
- long sum = 0; // sum of wxyz over w + x + y + z = 2011 % MOD
- long count = 0;
- for(w = 0; w <= 2011; ++w) {
- for(x = 0; x <= 2011 - w; ++x) {
- for(y = 0; y <= 2011 - w - x; ++y) {
- z = 2011 - w - x - y;
- // printf("%d %d %d %d\n", w, x, y, z);
- sum = (sum + w * x * y * z) % MOD;
- ++count;
- }
- }
- }
- printf("sum: %ld, terms: %ld\n", sum, count);
- // should give (2014 choose 7) % MOD, (2014 choose 3)
- }
Advertisement
Add Comment
Please, Sign In to add comment