弱校联萌十一大决战之如日中天 G Gadget Hackwrench
2015-10-04 20:08
465 查看
Input/Output: standard input/output
Chip 'n' Dale have started a new business in the forest: they produce tiles of fixed rectangular size and pave roads with them.
Road paving rules are the following. Starting from one corner of the rectangular road tiles are paved side-by-side without gaps or overlaps. Tiles can be cut into pieces to be used to pave the road if and only if
the whole tile doesn't fit. Each tile contains a pattern with parallel lines that must be retained on the paved road. This makes their orientation significant: any tile or its piece can not be rotated. All tile connection lines are straight, parallel to one
of the road edges and either perpendicular or parallel to each other. Chip 'n' Dale always pave the road so that each edge of a tile is adjacent to not more than one other tile, and they always pave the road with the least possible amount of tile pieces on
the road.
Given the size of the road and the size of one tile please help Chip 'n' Dale determine the number of tiles they need to produce to fully pave the road.
On the first line of input integers Widthroad and Lengthroad (1 ≤ Widthroad, Lengthroad ≤ 10 000)
are given — the width and the length of the road respectively.
On the second line of input integers Widthtile and Lengthtile (1 ≤ Widthtile ≤ Widthroad, 1 ≤ Lengthtile ≤ Lengthroad)
are given — the width and the length of the tile respectively.
The first line of the output should contain a single integer number N — the minimal
number of whole tiles needed to fully pave the road according to Chip 'n' Dale road paving rules.
Input
Output
Input
Output
Input
Output
链接
可惜了我久违的!A啊啊啊啊 时间不够了 没写完T^T 题意当中有个点 学弟读题没读出来 就是只能长边对长边 短边对短边!而且不能转 实在不行了才能裁
我读题还以为边角废料能凑在一起 后来学弟说要真能那么做 都裁成1x1的多好 哈哈 水题一个 就是一顿分类讨论 我丑陋的代码==
Chip 'n' Dale have started a new business in the forest: they produce tiles of fixed rectangular size and pave roads with them.
Road paving rules are the following. Starting from one corner of the rectangular road tiles are paved side-by-side without gaps or overlaps. Tiles can be cut into pieces to be used to pave the road if and only if
the whole tile doesn't fit. Each tile contains a pattern with parallel lines that must be retained on the paved road. This makes their orientation significant: any tile or its piece can not be rotated. All tile connection lines are straight, parallel to one
of the road edges and either perpendicular or parallel to each other. Chip 'n' Dale always pave the road so that each edge of a tile is adjacent to not more than one other tile, and they always pave the road with the least possible amount of tile pieces on
the road.
Given the size of the road and the size of one tile please help Chip 'n' Dale determine the number of tiles they need to produce to fully pave the road.
Input
On the first line of input integers Widthroad and Lengthroad (1 ≤ Widthroad, Lengthroad ≤ 10 000)are given — the width and the length of the road respectively.
On the second line of input integers Widthtile and Lengthtile (1 ≤ Widthtile ≤ Widthroad, 1 ≤ Lengthtile ≤ Lengthroad)
are given — the width and the length of the tile respectively.
Output
The first line of the output should contain a single integer number N — the minimalnumber of whole tiles needed to fully pave the road according to Chip 'n' Dale road paving rules.
Sample Input
Input10 10 2 2
Output
25
Input
3 5 2 2
Output
4
Input
35 17 25 1
Output
26
链接
可惜了我久违的!A啊啊啊啊 时间不够了 没写完T^T 题意当中有个点 学弟读题没读出来 就是只能长边对长边 短边对短边!而且不能转 实在不行了才能裁
我读题还以为边角废料能凑在一起 后来学弟说要真能那么做 都裁成1x1的多好 哈哈 水题一个 就是一顿分类讨论 我丑陋的代码==
#include <iostream> #include<cstdio> #include<cstring> using namespace std; int x,y,a,b; int main() { // freopen("cin.txt","r",stdin); while(~scanf("%d%d",&x,&y)) { scanf("%d%d",&a,&b); int sum=0; sum+=((x/a)*(y/b)); // printf("%d\n",sum); if((x%a==0)&&(y%b==0)) { printf("%d\n",sum); continue; } int ans1=x%a,ans2=y%b; // printf("%d %d\n",ans1,ans2); if(ans1==0) { if(ans2>(b)/2) { sum+=(x/a); printf("%d\n",sum); } else { int tmp=b/ans2,tmp2=x/a; sum+=tmp/tmp2; if(tmp2%tmp) sum++; printf("%d\n",sum); } continue; } if(ans2==0) { if(ans1>a/2) { sum+=y/b; printf("%d\n",sum); } else { int tmp=a/ans1,tmp2=y/b; sum+=tmp2/tmp; if(tmp2%tmp) sum++; printf("%d\n",sum); } continue; } if(ans1>(a)/2) { if(ans2>(b)/2) { sum+=x/a; sum+=(y/b+1); printf("%d\n",sum); } else { sum+=(y/b); int tmp=b/ans2; sum+=(x/(a*tmp)); if(x%(a*tmp))sum++; printf("%d\n",sum); } } else { if(ans2>(b)/2) { sum+=(x/a); int tmp=a/ans1; sum+=(y/(b*tmp)+1); printf("%d\n",sum); } else { int tmp1,tmp2,sum1=0,sum2=0; tmp1=y/b,tmp2=a/ans1; sum1=tmp1/tmp2; if(tmp1%tmp2) sum1++; tmp1=b/ans2; sum1+=(x/(tmp1*a)); if(x%(tmp1*a)) sum1++; tmp1=x/a,tmp2=b/ans2; sum2+=tmp1/tmp2; if(tmp1%tmp2) sum2++; tmp1=(a/ans1)*b; sum2+=(y/tmp1); if(y%tmp1) sum2++; if(sum1<sum2) sum+=sum1; else sum+=sum2; // printf("sum1=%d sum2=%d\n",sum1,sum2); printf("%d\n",sum); } } } return 0; }
相关文章推荐
- A018-布局之TableLayout
- 信息安全系统设计基础第四周学习总结
- 信息安全系统设计基础 第4周学习笔记
- Servlet的学习之Request请求对象(2)
- Java多态性理解
- main函数
- 线性筛
- 自己的练习二之构造函数与初始化列表
- 线性筛
- poj 1127 计算几何入门题 求线段交点
- Android Filter筛选ListView并且筛选内容变色
- HDOJ 5498 Tree
- Linux第三次学习笔记
- iOS按钮的使用和动画的实现
- curl是一个利用URL规则在命令行下工作的文件传输工具。
- 自己练习一之对象的访问和对象的存储和指针
- IMS技术
- ApplicationContext.xml 的最终xml声明,包括注解 aop
- 2015/10/04 阴雨天纪事
- android中listview 异步加载防止图片移位