-
Notifications
You must be signed in to change notification settings - Fork 0
/
21000_ArcherVlad.cpp
39 lines (36 loc) · 1019 Bytes
/
21000_ArcherVlad.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
#include <bits/stdc++.h>
#define endl "\n"
#define ll long long
#define INF 987654321
#define MAX 100001
#define int ll
using namespace std;
typedef pair<int, int> p;
int C, N;
double solvePos(int x, int y){
double VAL = x * pow(C, 2) + sqrt(pow(C, 4) * pow(x, 2) - 20 * pow(x, 2) * (y * pow(C, 2) + 5 * pow(x, 2)));
return VAL / (10 * pow(x, 2));
}
double solveMin(int x, int y){
double VAL = x * pow(C, 2) - sqrt(pow(C, 4) * pow(x, 2) - 20 * pow(x, 2) * (y * pow(C, 2) + 5 * pow(x, 2)));
return VAL / (10 * pow(x, 2));
}
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int tc; cin >> tc;
int a, b;
while(tc--){
double left = -INFINITY, right = INFINITY;
cin >> C >> N;
for(int i = 0; i < N; ++i){
cin >> a >> b;
left = max(left, solveMin(a, b));
right = min(right, solvePos(a, b));
}
cout << fixed;
cout.precision(3);
cout << (left + right) / 2 << endl;
}
return 0;
}