• 博客园logo
  • 会员
  • 周边
  • 新闻
  • 博问
  • 闪存
  • 众包
  • 赞助商
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
HaibaraAi
博客园    首页    新随笔    联系   管理    订阅  订阅

Warm up 15 Innovative Business

Innovative Business
Time Limit: 10000ms, Special Time Limit:25000ms, Memory Limit:65536KB
Total submit users: 16, Accepted users: 12
Problem 12774 : No special judgement
Problem description
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 6 Widthroad;Lengthroad 6 10 000) are given — the width and the length of the road respectively. On the second line of input integers Widthtile and Lengthtile (1 6 Widthtile 6 Widthroad, 1 6 Lengthtile 6 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 minimal number of whole tiles needed to fully pave the road according to Chip ’n’ Dale road paving rules.
Sample Input
10 10
2 2
3 5
2 2
35 17
25 1
Sample Output
25
4
26
Problem Source
HNU Contest 
Submit   Discuss   Judge Status  Problems  Ranklist 
 1 #pragma comment(linker, "/STACK:1024000000,1024000000")
 2 #include <map>
 3 #include <queue>
 4 #include <vector>
 5 #include <string>
 6 #include <cmath>
 7 #include <cstdio>
 8 #include <cstring>
 9 #include <cstdlib>
10 #include <iostream>
11 #include <algorithm>
12 using namespace std;
13 #define maxn 1305
14 #define ll long long
15 #define mod 1000000007
16 #define INF 0x7fffffff
17 #define eps 1e-8
18 ll n, m;
19 ll fun(double n, double m, double a, double b, double x, double y){
20     ll s1 = 0,s2=0;
21     if (y)s1 = ceil(n / ((int) floor(b / y)*a));
22     if (x)s2 = ceil((m - y) / ((int)floor(a / x)*b));
23     return s1+s2;
24 }
25 int main(){
26     /*int t;
27     scanf("%d", &t);
28     while (t--){
29     scanf("%I64d", &n);
30 
31     }*/
32     ll x, y, a, b, x1, x2, y1, y2, s1, s2;
33     while (~scanf("%I64d%I64d%I64d%I64d", &n, &m, &a, &b)){
34         ll s = (n / a)*(m / b);
35         x = n - n / a*a; y = m - m / b*b;
36         s1 = fun(1.0*n, 1.0*m, 1.0*a, 1.0*b,1.0*x,1.0*y);
37         s2 = fun(m*1.0,n*1.0,b*1.0,a*1.0,y*1.0,x*1.0);
38         s = s+min(s1, s2);
39         printf("%I64d\n", s);
40     }
41     return 0;
42 }
View Code

 

posted @ 2013-11-03 07:45  HaibaraAi  阅读(161)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2026
浙公网安备 33010602011771号 浙ICP备2021040463号-3