zoukankan
html css js c++ java
今天HNU的一道水题11018
水题 ~~~啥都不说了
水方法解决
#include
<
string
.h
>
#include
<
stdio.h
>
int
x1, y1, x2, y2;
double
seg[
100000
][
2
];
int
cnt;
int
res;
int
segb[
100000
];
double
total[
100000
][
2
];
int
xl,yl;
void
shadow()
{
double
x
=
xl,y
=
yl;
double
ax
=
x1,ay
=
y1,bx
=
x2,by
=
y2;
double
d1,d2;
d1
=
x
-
y
*
(x
-
ax)
/
(y
-
ay);
d2
=
x
-
y
*
(x
-
bx)
/
(y
-
by);
if
(d1
>
d2)
{
double
hold
=
d1;
d1
=
d2;
d2
=
hold;
}
seg[cnt][
0
]
=
d1;
seg[cnt][
1
]
=
d2;
segb[cnt]
=
1
;
cnt
++
;
}
void
cacul()
{
int
i
=
0
;
while
(i
<
cnt)
{
for
(
int
l
=
0
;l
<
cnt;l
++
)
{
if
(segb[l]
==
1
)
{
total[res][
0
]
=
seg[l][
0
];
total[res][
1
]
=
seg[l][
1
];
segb[l]
=
0
;
res
++
;
i
++
;
break
;
}
}
for
(
int
j
=
0
;j
<
res;j
++
)
{
int
k
=
0
;
for
(k
=
0
;k
<
cnt;k
++
)
{
if
(segb[k]
==
1
)
{
if
(total[j][
0
]
-
seg[k][
0
]
>=
0
&&
seg[k][
1
]
-
total[j][
0
]
>=
0
)
{
total[j][
0
]
=
seg[k][
0
];
if
(seg[k][
1
]
-
total[j][
1
]
>=
0
)
total[j][
1
]
=
seg[k][
1
];
i
++
;
segb[k]
=
0
;
k
=
0
;
}
else
if
(total[j][
1
]
-
seg[k][
0
]
>=
0
&&
seg[k][
1
]
-
total[j][
1
]
>=
0
)
{
total[j][
1
]
=
seg[k][
1
];
if
(total[j][
0
]
-
seg[k][
0
]
>=
0
)
total[j][
0
]
=
seg[k][
0
];
i
++
;
segb[k]
=
0
;
k
=
0
;
}
else
if
(seg[k][
0
]
-
total[j][
0
]
>=
0
&&
total[j][
1
]
-
seg[k][
1
]
>=
0
)
{
i
++
;
segb[k]
=
0
;
k
=
0
;
}
}
}
}
}
}
int
main()
{
int
n;
scanf(
"
%d
"
,
&
n);
for
(
int
i
=
0
;i
<
n;i
++
)
{
memset(seg,
0
,
sizeof
(seg));
memset(total,
0
,
sizeof
(total));
memset(segb,
0
,
sizeof
(segb));
cnt
=
0
;
res
=
0
;
int
m;
scanf(
"
%d
"
,
&
m);
scanf(
"
%d%d
"
,
&
xl,
&
yl);
for
(
int
j
=
0
;j
<
m;j
++
)
{
scanf(
"
%d%d%d%d
"
,
&
x1,
&
y1,
&
x2,
&
y2);
shadow();
}
cacul();
printf(
"
%d\n
"
,res
+
1
);
}
return
0
;
}
查看全文
相关阅读:
装配线调度
最长非降子序列
0-1背包问题
所有点对的最短路径问题
矩阵链相乘
最长公共子序列
最近点对问题
寻找多数元素
寻找第K小元素
java冒泡排序算法
原文地址:https://www.cnblogs.com/SQL/p/894313.html
最新文章
通过绕过验证的方式,请求rpc
Java中PO、BO、VO、DTO、POJO、DAO概念及其作用和项目实例图(转)
HTTP的POST方式
RPC服务和HTTP服务区分
简单的java编程(练手),日历的制作
Java MySQL 连接
TestNG常用的3种断言方法
Spring+Dubbo+TestNG接口测试
TestNG浅谈
URAL 1057 数位dp
热门文章
POJ1664 计数 DP
dpdpdpdp~~~!!!
心塞赛
USACO 刷题有感
USACO Section1.1PROB Broken Necklace
USACO Section 1.2PROB Miking Cows
USACO Section 1.2PROB Transformations
USACO Section 1.1PROB Your Ride Is Here
UVA 111 简单DP 但是有坑
硬币兑换问题
Copyright © 2011-2022 走看看