记录编号 |
84468 |
评测结果 |
AAAAAAAAAAA |
题目名称 |
[USACO Nov13]视线 |
最终得分 |
100 |
用户昵称 |
cstdio |
是否通过 |
通过 |
代码语言 |
C++ |
运行时间 |
0.162 s |
提交时间 |
2013-12-13 22:04:48 |
内存使用 |
0.31 MiB |
显示代码纯文本
- #include<iostream>
- #include<cstdio>
- #include<cmath>
- #include<algorithm>
- #include<cstring>
- #include<vector>
- #include<queue>
- #include<iomanip>
- using namespace std;
- #define pi 3.1415926535897932384626433832795028842
- #define SIZEN 50001
- vector<pair<double,double> > pa;
- double R;
- double deg(double x){
- return x/pi*180.0;
- }
- void tangent(double x,double y,double &a1,double &a2){//返回(x,y)到圆两切线的极角,储存在a1<a2中
- double temp;
- temp=acos(R/sqrt(x*x+y*y));
- a1=atan2(y,x)-temp;
- if(a1<0) a1+=2*pi;
- a2=a1+2*temp;
- }
- int N;
- int find(double x,int l,int r){
- if(l==r) return l;
- int mid=(l+r)>>1;
- if(pa[mid].first<x) return find(x,mid+1,r);
- else return find(x,l,mid);
- }
- int stat(int x){
- int ans=0,key;
- key=find(pa[x].second,0,pa.size()-1);
- return max(0,key-x-1);
- }
- void work(void){
- sort(pa.begin(),pa.end());
- int i;
- for(i=0;i<N;i++) pa.push_back(make_pair(pa[i].first+2*pi,pa[i].second+2*pi));
- int ans=0;
- for(i=0;i<N;i++) ans+=stat(i);
- printf("%d\n",ans);
- }
- void init(void){
- scanf("%d%lf",&N,&R);
- int i;
- double x,y;
- double a1,a2;
- for(i=1;i<=N;i++){
- scanf("%lf%lf",&x,&y);
- tangent(x,y,a1,a2);
- pa.push_back(make_pair(a1,a2));
- }
- }
- int main(){
- freopen("sight.in","r",stdin);
- freopen("sight.out","w",stdout);
- double a1,a2;
- init();
- work();
- return 0;
- }