比赛 |
20110414 |
评测结果 |
AWWWWTTTTT |
题目名称 |
数三角形 |
最终得分 |
10 |
用户昵称 |
magic |
运行时间 |
0.000 s |
代码语言 |
C++ |
内存使用 |
0.00 MiB |
提交时间 |
2011-04-14 11:09:05 |
显示代码纯文本
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#define maxcow 100001
int fir[maxcow],sec[maxcow],tri[maxcow],fou[maxcow];
int xl[maxcow],xr[maxcow],yu[maxcow],yd[maxcow];
int n,pos1,pos2,pos3,pos4,posx1,posx2,posy1,posy2;
int data[maxcow][2];
using namespace std;
double dis(int x1,int y1,int x2,int y2);
void init(int x,int y,int c);
bool success(int x,int y);
double dis(int x1,int y1,int x2,int y2)
{
double distance;
distance=sqrt(float((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)));
return (distance);
}
bool make(int p,int q);
bool make(int p,int q)
{
double k;
k=float(float(data[p][1])/float(data[p][0]));
if (k*data[q][0]-data[q][1]<0)
return (0);
else return(1);
}
void init(int x,int y,int c)
{
if ((x>0)&&(y>0))
{
pos1++;
fir[pos1]=c;
}
if ((x>0)&&(y<0))
{
pos4++;
fou[pos4]=c;
}
if ((x<0)&&(y>0))
{
pos2++;
sec[pos2]=c;
}
if ((x<0)&&(y<0))
{
pos3++;
tri[pos3]=c;
}
if ((x=0)&&(y>0))
{
posy1++;
yu[posy1]=c;
}if ((x=0)&&(y<0))
{
posy2++;
yd[posy2]=c;
}
if ((x>0)&&(y=0))
{
posx1++;
xr[pos1]=c;
}
if ((x<0)&&(y=0))
{
posx2++;
xl[posx2]=c;
}
}
bool success(int x,int y)
{
double a,b,c;
a=dis(data[x][0],data[x][1],0,0);
b=dis(data[y][0],data[y][1],0,0);
c=dis(data[x][0],data[x][1],data[y][0],data[y][1]);
if (a*a+b*b-c*c<0)
{
return (1);
}
else return(0);
}
int main()
{
int k,a,b,w,pos=0,j,ans=0;
freopen("tricount.in","r",stdin);
freopen("tricount.out","w",stdout);
scanf("%d",&n);
memset(data,0,sizeof(data));
memset(fir,0,sizeof(fir));
memset(sec,0,sizeof(sec));
memset(tri,0,sizeof(tri));
memset(fou,0,sizeof(fou));
for (k=1;k<=n;k++)
{
scanf("%d%d",&a,&b);
pos++;
data[pos][0]=a;
data[pos][1]=b;
init(a,b,pos);
}
for (k=1;k<=n;k++)
{
for (w=k;w<=n;w++)
{
if (k!=w)
{
if (success(k,w))
{
for (j=w;j<=n;j++)
{
if ((j!=k)||(j!=w))
{
if (make(k,j)==1||make(w,j)==1)
{
ans++;
}
}
}
}
}
}
}
printf("%d",ans/2);
return 0;
}