Repository navigation
Expand file tree
/
Copy path1002.cpp
More file actions
88 lines (84 loc) · 1.83 KB
/
Copy path1002.cpp
File metadata and controls
88 lines (84 loc) · 1.83 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#include "iostream"
#include "algorithm"
#include "cstdio"
#include "cstring"
#include "set"
#include "vector"
#include "queue"
#include "map"
#include "cmath"
#include "ctime"
#include "stack"
using namespace std;
typedef long long LL;
const int MOD = 1000000007;
const int MAXN = 100000+10;
const double PI = acos((double)-1);
typedef pair< int , int > PII;
struct arrow{
double l;
double r;
int pos;
double x;
bool operator<(arrow a)const{
return x<a.x;
}
arrow(){}
arrow(double X){
x = X;
}
}dp[MAXN];
struct node{
double x,y;
bool operator<(node a)const{
return y>a.y;
}
}Build[MAXN];
void Rupdata(int l,int r,int p){
double row;
for(;l<r;l++){
row = Build[p].y/(dp[l].x-Build[p].x);
if(row<=dp[l].r)return;
dp[l].r = row;
}
}
void Lupdata(int l,int r,int p){
double row;
for(;r>=l;r--){
row = Build[p].y/(Build[p].x-dp[r].x);
if(row<=dp[r].l)return;
dp[r].l = row;
}
}
double ans[MAXN];
int main()
{
int T;
scanf("%d",&T);
for(int t=1;t<=T;t++){
int N,Q;
scanf("%d",&N);
for(int i = 0;i<N;i++)scanf("%lf%lf",&Build[i].x,&Build[i].y);
sort(Build,Build+N);
scanf("%d",&Q);
for(int i=0;i<Q;i++){
scanf("%lf",&dp[i].x);
dp[i].pos=i;
dp[i].l=0;
dp[i].r=0;
}sort(dp,dp+Q);
for(int i=0;i<N;i++){
int pos = lower_bound(dp,dp+Q,arrow(Build[i].x))-dp;
Rupdata(pos,Q,i);
Lupdata(0,pos-1,i);
}
for(int i=0;i<Q;i++){
//cout<<dp[i].l<<endl;
ans[dp[i].pos] = (PI - atan(dp[i].l)-atan(dp[i].r))*180.0/PI;
}
printf("Case #%d:\n",t);
for(int i=0;i<Q;i++)
printf("%.10lf\n",ans[i]);
}
return 0;
}