比赛 |
20131207 |
评测结果 |
AWWWWTTTTTW |
题目名称 |
视线 |
最终得分 |
9 |
用户昵称 |
超级傲娇的AC酱 |
运行时间 |
5.366 s |
代码语言 |
C++ |
内存使用 |
0.31 MiB |
提交时间 |
2013-12-07 15:34:37 |
显示代码纯文本
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<vector>
using namespace std;
double Dis(double,double,double,double);
int main()
{
freopen("sight.in","r",stdin);
freopen("sight.out","w",stdout);
ios::sync_with_stdio(false);
int n,i,j,Ans=0;
double R,q,p;
cin>>n>>R;
const int Len=n;
vector<double>x(Len);
vector<double>y(Len);
//vector<double>x,y;
for(i=0;i<n;i++)
{
cin>>x[i]>>y[i];
//x.push_back(p);
//y.push_back(q);
}
for(i=0;i<x.size()-1;i++)
for(j=i+1;j<x.size();j++)
{
/*double A,B,C,Dis;
A=y[i]-y[j];
B=x[j]-x[i];
C=(y[i]*B+x[i]*A);
Dis=(C*C)/(A*A+B*B);
*/
/*if(Dis>=R*R)
{
Ans++;
cout<<x[i]<<' '<<y[i]<<' '<<x[j]<<' '<<y[j]<<endl;
}
*/
if(Dis(x[i],y[i],x[j],y[j])>=R*R)
Ans++;
}
//Ans;
cout<<Ans;
return 0;
}
double Dis(double x1,double y1,double x2,double y2)
{
//double Px1=double(x1),Py1=double(y1), Px2=double(x2),Py2=double(y2),A,B,C,Dis;
double A,B,C,dis;
A=y1-y2;
B=x2-x1;
C=(y1*B+x1*A);
dis=(C*C)/(A*A+B*B);
return dis;
}