nickel2halide

234

Nov 16th, 2011
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.55 KB | None | 0 0
  1. #include <stdlib.h>
  2. #include <stdio.h>
  3.  
  4. int MOD = 12582917;
  5.  
  6. int main()
  7. {
  8.   int w, x, y, z;
  9.   int sum = 0; // sum of wxyz over w + x + y + z = 2011 % MOD
  10.   int 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);
  23.   // should give (2014 choose 7) % MOD, (2014 choose 3)
  24. }
  25.  
  26.  
Advertisement
Add Comment
Please, Sign In to add comment