-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1007.cpp
More file actions
49 lines (44 loc) · 1.2 KB
/
Copy path1007.cpp
File metadata and controls
49 lines (44 loc) · 1.2 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
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#define INF 1e9
using namespace std;
int main() {
int TC; cin >> TC;
while(TC--){
int n,sum_x,sum_y;
long long ans = -1,now;
vector < pair <int,int> > point;
vector <int> comb;
cin >> n;
point.resize(n);
comb.resize(n,0);
for(int i = 0 ; i < n ; i++){
cin >> point[i].first >> point[i].second;
if( i >= n /2)
comb[i] = 1;
}
do{
sum_x = sum_y = 0;
for(int i = 0 ; i < n ;i++){
if(comb[i]){
sum_x += point[i].first;
sum_y += point[i].second;
}
else{
sum_x -= point[i].first;
sum_y -= point[i].second;
}
}
now = pow(sum_x,2) + pow(sum_y,2);
if(ans == -1 || ans > now)
ans = now;
}while(next_permutation(comb.begin(),comb.end()));
cout << fixed;
cout.precision(12);
cout << sqrt(ans) << '\n';
}
return 0;
}