-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathE.cpp
More file actions
69 lines (66 loc) · 1.67 KB
/
E.cpp
File metadata and controls
69 lines (66 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#include <iostream>
using namespace std;
// Driver Code
int main() {
int M = 0;
int N = 0;
int K = 0;
int permutacion = 1;
cin >> M >> N >> K;
//numero de conbinaciones
int matriz[M][N];
if(M == N && N == K){
int contador = 0;
for(int i =0; i < N; i++){
contador = contador + 1;
permutacion = contador*permutacion;
}
cout << permutacion << endl;
}
else if(N == 1){
cout << 1 << endl;
}
else if(M == 1){
permutacion = N;
}
else if(N == M && K ==1){
permutacion = N;
}
else if( N == K){
int factorial = 1;
int contador = 0;
for(int i =0; i < N; i++){
contador = contador + 1;
factorial = contador*factorial;
}
int factorial2 = 1;
int contador2 = 0;
int abajo = (N - M);
for(int i =0; i < abajo; i++){
contador2 = contador2 + 1;
factorial2= contador*factorial2;
}
permutacion = factorial/(factorial2);
}
else{
int factorial = 1;
int contador = 0;
for(int i =0; i < N; i++){
contador = contador + 1;
factorial = contador*factorial;
}
int factorial2 = 1;
int contador2 = 0;
for(int i =0; i < M; i++){
contador2 = contador2 + 1;
factorial2= contador*factorial2;
}
int factorial3 = 1;
int contador3 = 0;
for(int i =0; i < K; i++){
contador = contador + 1;
factorial = contador*factorial;
}
permutacion = (factorial * factorial2)/factorial3;
}
}