为什么会这样。。。。

P2665 [USACO08FEB] Game of Lines S

0.0不是加到set里了吗,最后应该要-1吧
by t162 @ 2019-01-25 14:52:55


@[Bambusoideae](/space/show?uid=106140) 可是答案比样例少了1....
by Hiraeth @ 2019-01-25 15:00:25


@[Bambusoideae](/space/show?uid=106140) 好像知道我哪里错了 横坐标相等的时候斜率是不存在而不是为0……
by Hiraeth @ 2019-01-25 15:02:00


为什么会这样呢。。明明。。明明是对的啊(跑
by NaCly_Fish @ 2019-01-25 15:09:35


@[Hiraeth](/space/show?uid=99460) 所以你现在对了吗?我发现我的做法和你差不多,但有几个点过不去
by Rena @ 2019-04-09 17:59:20


@[Hiraeth](/space/show?uid=99460) 可以讲一讲吗?O(∩_∩)O谢谢
by Rena @ 2019-04-09 17:59:40


@[Rena](/space/show?uid=153893) 横坐标相等的时候斜率是不存在而不是为0 你可能这个地方判断错了
by Hiraeth @ 2019-04-09 19:49:08


@[Hiraeth](/space/show?uid=99460) 这个我特判了的,改了一下还是不行
by Rena @ 2019-04-11 08:40:19


```cpp #include<set> #include<cstdio> #include<cstdlib> #include<cmath> #include<cstring> #include<iostream> #include<algorithm> using namespace std; int n; struct TI { int xx,yy; }u[2003]; set <double> s; int main() { cin>>n; for(int i=1;i<=n;++i) { scanf("%d%d",&u[i].xx,&u[i].yy); } for(int i=1;i<=n;++i) { for(int j=1;j<=n;++j) { if(i!=j&&u[i].xx!=u[j].xx) { if(u[i].yy ==u[j].yy )s.insert(0.0); else s.insert((double)(u[j].yy-u[i].yy)/(u[j].xx-u[i].xx)); } } } cout<<s.size(); return 0; } ``` @[Hiraeth](/space/show?uid=99460)
by Rena @ 2019-04-11 08:41:51


|