Browse Source

Add 'I.cpp'

webturing 4 years ago
parent
commit
4392354998
1 changed files with 23 additions and 0 deletions
  1. 23 0
      I.cpp

+ 23 - 0
I.cpp

@@ -0,0 +1,23 @@
+#include<bits/stdc++.h>
+using namespace std;
+using ll = long long;
+ll Cnr(int n, int r) {
+    ll s = 1;
+    if (r * 2 > n) {
+        r = n - r;
+    }
+    for (int i = 0; i < r; i++) {
+        s *= (n - i);
+    }
+    for (int i = r; i >= 2; i--) {
+        s /= i;
+    }
+    return s;
+}
+int main() {
+    int n, r;
+    while (cin >> n >> r) {
+        cout << Cnr(n, r) << endl;
+    }
+    return 0;
+}