zoukankan
html css js c++ java
PKU3327
WA了N次...
#include
<
string
.h
>
#include
<
stdio.h
>
struct
Rect
{
int
w, d;
}
;
int
c, w, d, cnt, p, s;
Rect rect[
110
];
int
area[
110
];
void
cut()
{
int
hw
=
rect[p].w, hd
=
rect[p].d ;
s
%=
(
2
*
(hw
+
hd));
rect[cnt]
=
rect[p];
if
(s
>
0
&&
s
<
hw)
{
rect[p].w
=
s,rect[p].d
=
hd;
rect[cnt].w
=
hw
-
rect[p].w;
}
if
(s
>
hw
&&
s
<
hw
+
hd)
{
rect[p].w
=
hw,rect[p].d
=
s
-
hw;
rect[cnt].d
=
hd
-
rect[p].d;
}
if
(s
>
hw
+
hd
&&
s
<
2
*
hw
+
hd)
{
rect[p].w
=
s
-
hw
-
hd,rect[p].d
=
hd;
rect[cnt].w
=
hw
-
rect[p].w;
}
if
(s
>
2
*
hw
+
hd
&&
s
<
2
*
hw
+
2
*
hd)
{
rect[p].w
=
hw,rect[p].d
=
s
-
2
*
hw
-
hd;
rect[cnt].d
=
hd
-
rect[p].d;
}
//
if
(rect[p].w
*
rect[p].d
>
rect[cnt].d
*
rect[cnt].w)
{
Rect hr
=
rect[p];
rect[p]
=
rect[cnt];
rect[cnt]
=
hr;
}
Rect hr1=rect[p];
int i;
for(i=p;i<cnt-1;i++)
rect[i]=rect[i+1];
rect[cnt-1]=hr1;
}
int
main()
{
while
(scanf(
"
%d%d%d
"
,
&
c,
&
w,
&
d)
==
3
)
{
if
(c
==
0
&&
w
==
0
&&
d
==
0
)
break
;
cnt
=
1
;
int
i, j;
for
(i
=
0
;i
<
110
;i
++
)
rect[i].d
=
rect[i].w
=
area[i]
=
0
;
rect[
1
].w
=
w,rect[
1
].d
=
d;
for
(i
=
1
;i
<=
c;i
++
)
{
scanf(
"
%d%d
"
,
&
p,
&
s);
cnt
++
;
cut();
}
for
(i
=
1
;i
<=
c
+
1
;i
++
)
{
//
printf("%d : %d , %d \n",i,rect[i].w,rect[i].d);
int
harea
=
rect[i].w
*
rect[i].d;
for
(j
=
i;j
>=
1
;j
--
)
{
area[j]
=
area[j
-
1
];
if
(harea
>
area[j])
{
area[j]
=
harea;
break
;
}
}
}
for
(i
=
1
;i
<=
c
+
1
;i
++
)
{
if
(i
!=
1
)printf(
"
"
);
printf(
"
%d
"
,area[i]);
}
printf(
"
\n
"
);
}
return
0
;
}
查看全文
相关阅读:
python中有哪些类型的布尔值是False?
django中间件(获取请求ip)
用python进行月份加减的函数
Python取整函数
Python里面search()和match()的区别
在追灿公司的学习笔记
Maven学习笔记
天梯赛练习 L3-006 迎风一刀斩 (30分) 几何关系
PAT甲级 1155 Heap Paths (30分) 堆模拟
天梯赛练习 L3-016 二叉搜索树的结构 (30分)
原文地址:https://www.cnblogs.com/SQL/p/913090.html
最新文章
win10在python3.6里安装pycrypto-2.6.1
python调用dll详解
Dart学习笔记-循环
Dart学习笔记-运算符-条件表达式-类型转换
Dart学习笔记-变量常量数据类型
win10安装mysql-最简单教程
域名查询是否注册的demo
python生成密码字典
python检测进程是否存在
python分割txt文件
热门文章
在Ubuntu中安装Docker和docker的使用
ubuntu服务器允许Root用户登录
PyQt5学习一---环境的安装和配置
Git简易的命令行入门教程:
Django开启https(不用nginx)
自动爬取代理IP例子
阿里云对象存储调用例子
百度人脸识别python调用例子
sql优化的几种方法
django框架ORM数据库
Copyright © 2011-2022 走看看