Elevator poj3539
Time Limit: 4000MS | Memory Limit: 65536K | |
Total Submissions: 1072 | Accepted: 287 | |
Case Time Limit: 2000MS |
Description
Edward works as an engineer for Non-trivial Elevators: Engineering, Research and Construction (NEERC). His new task is to design a brand new elevator for a skyscraper with h floors.
Edward has an idée fixe: he thinks that four buttons are enough to control the movement of the elevator. His last proposal suggests the following four buttons:
- Move a floors up.
- Move b floors up.
- Move c floors up.
- Return to the first floor.
Initially, the elevator is on the first floor. A passenger uses the first three buttons to reach the floor she needs. If a passenger tries to move a, b or c floors up and there is no such floor (she attempts to move higher than the h-th floor), the elevator doesn’t move.
To prove his plan worthy, Edward wants to know how many floors are actually accessible from the first floor via his elevator. Help him calculate this number.
Input
The first line of the input file contains one integer h — the height of the skyscraper (1 ≤ h ≤ 1018).
The second line contains three integers a, b and c — the parameters of the buttons (1 ≤ a, b, c ≤ 100 000).
Output
Output one integer number — the number of floors that are reachable from the first floor.
Sample Input
- 15
- 4 7 9
Sample Output
- 9
- #include <iostream>
- #include <stdio.h>
- #include <string.h>
- #include <math.h>
- #include <vector>
- #include <queue>
- using namespace std;
- #define ll long long
- ll bb[];
- ll a,b,c;
- priority_queue<ll,vector<ll>,greater<ll> > q;
- void bfs()
- {
- while(!q.empty())q.pop();
- q.push(+a),q.push(+b),q.push(+c);
- ll d,i=;
- while(!q.empty())
- {
- d=q.top();
- q.pop();
- if(bb[d%a]!=-&&bb[d%a]<=d)continue;
- bb[d%a]=d;
- i++;
- if(i==a)return ;
- q.push(d+b);
- q.push(d+c);
- }
- }
- int main()
- {
- ll h,ans;
- ll i;
- while(~scanf("%I64d",&h))
- {
- scanf("%I64d%I64d%I64d",&a,&b,&c);
- if(a>b)swap(a,b);
- if(a>c)swap(a,c);
- memset(bb,-,sizeof(bb));
- bfs();
- ans=;
- for(i=; i<a; i++)
- {
- // cout<<bb[i]<<" ";
- if(bb[i]==-||h<bb[i])continue;
- ans+=(h-bb[i]+)/a;
- if((h-bb[i]+)%a)ans++;
- }
- // cout<<endl;
- printf("%I64d\n",ans+);
- }
- }
Elevator poj3539的更多相关文章
- POJ3539 Elevator
Time Limit: 4000MS Memory Limit: 65536KB 64bit IO Format: %lld & %llu Description Edward wor ...
- poj3539 Elevator——同余类bfs
题目:http://poj.org/problem?id=3539 题目大意是给定 a, b, c,求 1~h 内有多少个数可以被 a, b, c 通过加减法组成: 这是今天刚讲的神奇的——同余类 b ...
- HDOJ 1008. Elevator 简单模拟水题
Elevator Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Su ...
- poj[2392]space elevator
Description The cows are going to space! They plan to achieve orbit by building a sort of space elev ...
- Design Elevator
From: https://discuss.leetcode.com/topic/89/write-elevator-program-using-event-driven-programming/9 ...
- PAT (Advanced Level) Practise:1008. Elevator
[题目链接] The highest building in our city has only one elevator. A request list is made up with N posi ...
- Pair Project: Elevator Scheduler [电梯调度算法的实现和测试]
作业提交时间:10月9日上课前. Design and implement an Elevator Scheduler to aim for both correctness and performa ...
- POJ2392Space Elevator(贪心+背包)
Space Elevator Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 9970 Accepted: 4738 De ...
- hdu 1008 Elevator
Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Description The hig ...
随机推荐
- SSH2项目网上书店系统手把手教学_Struts2+Spring+Hibernate整合开发
一 序言 鉴于目前J2EE的火热程度,SSH2是每个学生毕业前都必须掌握的一门技术,所以在这里我就使用SSH2技术做一个小型项目,和大家一起学习. SSH2技术的基础概论就不再提了,直接说特点吧. 1 ...
- ORACLE SEQUENCE的简单介绍
先假设有这么一个表: create table S_Depart ( DepartId INT not null, DepartName NVARCHAR2() not null, DepartOrd ...
- Google推出移动网页开发者认证考试 价格99美元
如果您是移动网页开发人员,希望了解您的编码实力,Google将推出一个认证流程,让您可以参加考试,如果您通过,可以在您的简历,网站和其他在线上显示电子徽章配置文件. 此外,潜在的雇 ...
- 深度神经网络在量化交易里的应用 之二 -- 用深度网络(LSTM)预测5日收盘价格
距离上一篇文章,正好两个星期. 这边文章9月15日 16:30 开始写. 可能几个小时后就写完了.用一句粗俗的话说, "当你怀孕的时候,别人都知道你怀孕了, 但不知道你被日了多少回 ...
- 团队作业八——第二次团队冲刺(Beta版本)第5天
团队作业八--第二次团队冲刺(Beta版本)第5天 一.每个人的工作 (1) 昨天已完成的工作 完成界面跳转界面. (2) 今天计划完成的工作 简单模式逻辑代码涉及与相关功能的具体实现 (3) 工作中 ...
- 201521123107 《Java程序设计》第4周学习总结
第4周作业-面向对象设计与继承 1.本周学习总结 2.书面作业 1.注释的应用 使用类的注释与方法的注释为前面编写的类与方法进行注释,并在Eclipse中查看.(截图) 对类的注释: 所得到的效果: ...
- 201521123022 《Java程序设计》 第七周学习总结
1. 本周学习总结 以你喜欢的方式(思维导图或其他)归纳总结集合相关内容. 2. 书面作业 Q1.ArrayList代码分析 Q1.1 解释ArrayList的contains源代码 ArrayLis ...
- 201521123050 《Java程序设计》第5周学习总结
1. 本周学习总结 2. 书面作业 1.代码阅读:Child压缩包内源代码 1.1 com.parent包中Child.java文件能否编译通过?哪句会出现错误?试改正该错误.并分析输出结果. 答:不 ...
- 《JAVA程序设计》第10周学习总结
1. 本章学习总结 1.1 以你喜欢的方式(思维导图或其他)归纳总结异常与多线程相关内容. 2. 书面作业 1.finally 题目4-2 1.1 截图你的提交结果(出现学号) 1.2 4-2中fin ...
- 201521123075 《Java程序设计》第14周学习总结
1. 本周学习总结 2. 书面作业 1. MySQL数据库基本操作 建立数据库,将自己的姓名.学号作为一条记录插入.(截图,需出现自己的学号.姓名) 在自己建立的数据库上执行常见SQL语句(截图) 参 ...