forked from spbsu-student-projects/permanent
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSource.cpp
More file actions
56 lines (56 loc) · 1.21 KB
/
Source.cpp
File metadata and controls
56 lines (56 loc) · 1.21 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
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <vector>
#include <map>
#include <algorithm>
#include <set>
#include <math.h>
#include "polynom.h"
#include <string>
#include <fstream>
#include <ctime>
#include <iomanip>
using namespace std;
string s;
vector<vector<polynom> > matr;
int n;
vector<int> perm;
polynom res;
int main(){
cin >> n;
matr.resize(n);
for (int i = 0; i < n; i++){
for (int j = 0; j < n; j++){
cin >> s;
matr[i].push_back(polynom_make_polynom(s));
}
}
int pow2 = 1 << n;
for (int i = 0; i < pow2; i++) {
vector<bool> take(n);
int x = i;
int s = 0;
for (int j = 0; j < n; j++) {
if (x == 0) break;
if (x % 2) {
take[j] = true;
s++;
}
x /= 2;
}
polynom summator;
if (s % 2 != 0) summator = polynom(-1);
else summator = polynom(1);
for (int j = 0; j < n; j++) {
polynom sum;
for (int k = 0; k < n; k++) {
if (take[k]) sum += matr[j][k];
}
summator *= sum;
}
res += summator;
}
if (n % 2 != 0) res = res * polynom(-1);
cout << res << endl;
return 0;
}