Advertisement
GeeckoDev

pe60

May 29th, 2012
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.66 KB | None | 0 0
  1. #include <iostream>
  2. #include <gmpxx.h>
  3.  
  4. mpz_class C(int n, int r)
  5. {
  6.     mpz_class fact_n;
  7.     mpz_class fact_r;
  8.     mpz_class fact_n_r;
  9.    
  10.     mpz_fac_ui(fact_n.get_mpz_t(), n);
  11.     mpz_fac_ui(fact_r.get_mpz_t(), r);
  12.     mpz_fac_ui(fact_n_r.get_mpz_t(), n-r);
  13.    
  14.     return fact_n / (fact_r * fact_n_r);
  15. }
  16.  
  17. int main()
  18. {
  19.     int count = 0, mcount;
  20.  
  21.     for (int n=23; n<=100; n++)
  22.     {
  23.         mcount = 0;
  24.  
  25.         for (int r=0; r<=n; r++, mcount++)
  26.         {
  27.             if (C(n, r) > 1000000)
  28.                 break;
  29.         }
  30.        
  31.         count += n - 2*mcount + 1;
  32.     }
  33.    
  34.     std::cout << count << std::endl;
  35.     return 0;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement