-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy path844-B.cpp
43 lines (37 loc) · 883 Bytes
/
844-B.cpp
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
/*
math > combinatorics > combinations > binomial coefficient
difficulty: easy
date: 27/Dec/2019
by: @brpapa
*/
#include <cmath>
#include <iostream>
#define MAX 50
using namespace std;
typedef long long int lli;
int main() {
int R, C;
cin >> R >> C;
int t[MAX][MAX];
for (int r = 0; r < R; r++)
for (int c = 0; c < C; c++)
cin >> t[r][c];
lli ans = 0;
for (int r = 0; r < R; r++) {
int qty[2] = {0, 0};
for (int c = 0; c < C; c++)
qty[t[r][c]]++;
ans += (lli)pow(2, qty[0]) - 1;
ans += (lli)pow(2, qty[1]) - 1;
}
for (int c = 0; c < C; c++) {
int qty[2] = {0, 0};
for (int r = 0; r < R; r++)
qty[t[r][c]]++;
ans += (lli)pow(2, qty[0]) - 1;
ans += (lli)pow(2, qty[1]) - 1;
}
ans -= R * C; // conjuntos de 1 elemento
cout << ans << endl;
return 0;
}