-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1865.cpp
More file actions
61 lines (55 loc) · 933 Bytes
/
1865.cpp
File metadata and controls
61 lines (55 loc) · 933 Bytes
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
// 1865. 동철이의 일 분배
// 2019.07.17
// 브루트 포스
#include<iostream>
#include<algorithm>
using namespace std;
double task[17][17];
bool visit[17];
int n;
double ans;
// 일을 분배하는 모든 경우의 수를 확인
void go(int cnt, double tmp)
{
if (cnt == n)
{
ans = max(tmp, ans);
return;
}
double t = tmp;
for (int i = 0; i < n; i++)
{
if (!visit[i] && tmp * task[cnt][i] > ans)
{
visit[i] = true;
go(cnt + 1, tmp * task[cnt][i]);
tmp = t;
visit[i] = false;
}
}
}
int main()
{
int t;
cin >> t;
for (int testCase = 1; testCase <= t; testCase++) {
cin >> n;
for (int i = 0; i < 17; i++)
{
fill(task[i], task[i] + 17, 0.0);
}
fill(visit, visit + 17, 0);
ans = 0;
for (int i = 0; i < n; i++)
{
for (int j = 0; j < n; j++)
{
cin >> task[i][j];
task[i][j] *= 0.01;
}
}
go(0, 100);
printf("#%d %.6f\n", testCase, ans);
}
return 0;
}