Advertisement
Guest User

Untitled

a guest
Feb 28th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. #include <vector>
  4. #include <string>
  5. #include <algorithm>
  6. #include <fstream>
  7. #include <set>
  8. #include <iomanip>
  9. #include <iso646.h>
  10. #include <stdio.h>
  11. #include <map>
  12. #define sync ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
  13. #define ss second
  14. #define ff first
  15. #define ll long long
  16. #define mp make_pair
  17. #define endl "\n"
  18. #define pb push_back
  19. #define ld long double
  20. #define M_PI 3.14159265358979323846 /* pi */
  21. const double EPS = 0.0000000001;
  22. using namespace std;
  23. const ll INF = 1000000007;
  24.  
  25. ll binpow(ll a, ll n) {
  26. ll res = 1;
  27. while (n) {
  28. if (n & 1)
  29. {
  30. res *= a;
  31. res %= INF;
  32. n--;
  33. }
  34. else
  35. {
  36. a *= a;
  37. a %= INF;
  38. n /= 2;
  39. }
  40. }
  41. return res;
  42. }
  43.  
  44. ll C(ll n, ll k) {
  45. ll res = 1;
  46. for (int i = 1; i <= k; ++i)
  47. res = (res * (n - k + i) % INF*binpow(i, INF - 2))%INF;
  48. return res;
  49. }
  50.  
  51. int main()
  52. {
  53. sync;
  54. ll n, k;
  55. cin >> n >> k;
  56. cout << C(n - 1, n - k)%INF;
  57. return 0;
  58.  
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement