There was an error while loading. Please reload this page.
1 parent 7a89191 commit f22e190Copy full SHA for f22e190
Online Judges/URI/1936.cpp
@@ -0,0 +1,35 @@
1
+#include <iostream>
2
+#include <map>
3
+
4
+using namespace std;
5
6
+map<int, int> ma {
7
+ {1,1},
8
+ {2,2},
9
+ {3,6},
10
+ {4,24},
11
+ {5,120},
12
+ {6,720},
13
+ {7,5040},
14
+ {8,40320}
15
+};
16
17
+int main() {
18
+ int a, i = 8, cont = 0;
19
+ cin >> a;
20
+ int sum = a;
21
+ while(sum) {
22
+ if (ma.at(i) > sum) {
23
+ i--;
24
+ } else if (ma.at(i) == a) {
25
+ cont++; break;
26
+ } else {
27
+ sum-=ma.at(i);
28
+ cont++;
29
+ }
30
31
32
+ cout << cont << endl;
33
+ return 0;
34
+}
35
0 commit comments