F.A.Qs Home ProblemSet Status Ranklist Contest LoginRegister
Notice:1:五月份月赛定于5.27日12:30--17:30,欢迎大家来玩! 2:关于OJ的注册可看https://www.lydsy.com/JudgeOnline/wttl/thread.php?tid=5671
大视野在线测评-欢迎您
[ New Thread ]
Problem 1132 >> 为什么WA?本地测AC!
sweetdum @ 2013-03-25 17:00:49
[ Quote ] [ Edit ] [ Delete ] 1#
#include<cstdio>
#include<algorithm>
#include<iostream>
struct point
{
long long x,y;
}a[3010],temp[3010];
int n,i,j,tot;
long long sx,sy,ans;
bool cmp(point A,point B)
{
return A.x*B.y<A.y*B.x;
}
bool cmp1(point A,point B)
{
return A.x<B.x||(A.x==B.x&&A.y<B.y);
}
using namespace std;
int main()
{
scanf("%d",&n);
for (i=1;i<=n;i++) scanf("%lld%lld",&a[i].x,&a[i].y);
sort(a+1,a+n+1,cmp1);
for (i=1;i<=n-2;i++)
{
tot=0;
for(j=i+1;j<=n;++j) temp[++tot]=a[j];
for (j=1;j<=tot;j++)
{
temp[j].x-=a[i].x;
temp[j].y-=a[i].y;
}
sort(temp+1,temp+tot+1,cmp);
sx=0;sy=0;
for (j=1;j<=tot;j++)
{
ans+=temp[j].x*sy-temp[j].y*sx;
sx+=temp[j].x;sy+=temp[j].y;
}
}
ans*=10;
ans/=2;
cout<<ans/10<<"."<<ans%10<<endl;
return 0;
}
sweetdum @ 2013-03-29 11:30:36
[ Quote ] [ Edit ] [ Delete ] 2#
急求!
lavendir @ 2013-03-29 11:57:46
[ Quote ] [ Edit ] [ Delete ] 3#
精度问题。
Fuxey @ 2016-02-16 11:33:27
[ Quote ] [ Edit ] [ Delete ] 4#
你只用把结构体里的long long改成int 就可以啦 , 此评测有毒
Fuxey @ 2016-02-16 11:34:26
[ Quote ] [ Edit ] [ Delete ] 5#
我的结构体是:
struct points
{
int x , y;
void read() { scanf("%d%d" ,&x , &y); }
points(ll x = 0 , ll y = 0):x(x),y(y){}
bool operator <(const points& b)const { return x<b.x || (x==b.x && y<b.y); }
};

然而 , 如果我用long long , 就挂掉……QAQ
lichangdongtw @ 2017-12-08 09:19:41
[ Quote ] [ Edit ] [ Delete ] 6#
同long long改int就A了TAT
[Top] [Previous Page] [Next Page]

HOME Back