[POJ] 3539 Elevator】的更多相关文章

题目:http://poj.org/problem?id=3539 考虑把层数分为模a剩余系.同类内可通过+若干个a走到. 不同类之间需要通过+b.+c来走到. 需要求出每一类中最小的能走到的.即最短路. 注意memset成0x3f!不要直接memset成1! 仔细一看,long long下赋1是17位,赋0x3f是19位.而h是18位. #include<iostream> #include<cstdio> #include<cstring> #include<…
http://poj.org/problem?id=3539 给定一个电梯,可以上升a,b,c层和回到1层,给定楼高h,求可达层数 lyd讲的同余类BFS,方法是先把三个量压成两个,即把h%a,因为对于一个x∈{h%a},若x可达,则x+ak一定可达. 然后考虑在这个模a的剩余系中,b和c的情况. 从1开始连边,从点i连向(i+w)%a,代价为w,其中w为b或c. 意义就是,对于一个楼层x,从x到达最近x+w层的代价为w,这很显然. 从1开始做单源最短路,然后只需要统计dis小于等于h的,大于的…
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…
题意 有一部电梯,最初停在1层. 电梯有4个按键,上升a,b,c层,回到一层. 求从一层出发.能到达1~h的哪些楼层. (h<=1018,a,b,c<=105) 题解 这种h能大的图论,一眼就知道是同余类. 以模a[1]的余数为下标建立数组,数组的意义是模a[1]为下标的最小的能到达的值. 显然之后的相同模数的楼层都可以达到.统计答案即可. 处理数组用最短路就行. #include<iostream> #include<cstring> #include<algo…
Description Too worrying about the house price bubble, poor Mike sold his house and rent an apartment in a 50-floor building several months ago. This building has only one elevator because it is a so called “rotten tail building”. There are always a…
Description The cows are going to space! They plan to achieve orbit by building a sort of space elevator: a giant tower of blocks. They have K ( <= K <= ) different types of blocks with which to build the tower. Each block of type i has height h_i (…
POJ 2392 Space Elevator(贪心+多重背包) http://poj.org/problem?id=2392 题意: 题意:给定n种积木.每种积木都有一个高度h[i],一个数量num[i].另一个限制条件,这个积木所在的位置不能高于limit[i],问能叠起的最大高度? 分析: 本题是一道多重背包问题, 只是每一个物品的选择不只要受该种物品的数量num[i]限制, 且该物品还受到limit[i]的限制. 这里有一个贪心的结论: 我们每次背包选取物品时都应该优先放置当前limit…
Description The cows are going to space! They plan to achieve orbit by building a sort of space elevator: a giant tower of blocks. They have K (1 <= K <= 400) different types of blocks with which to build the tower. Each block of type i has height h…
该题与POJ 1742的思路基本一致:http://www.cnblogs.com/sevenun/p/5442279.html(多重背包) 题意:给你n个电梯,第i个电梯高h[i],数量有c[i]个,但是每个电梯所在高度不能超过a[i]. 求问,怎么样的建造方案能够使电梯能够达到最大高度 思路:首先,必然要使电梯按a[i]进行排序,a[i]最小的电梯先建造.例如,电梯1,只能在高度20以下建造,而电梯2能在高度50以下建造,我当然先建造电梯1,否则如果先建造电梯2,就会导致我建造的高度早早超过…
Q: 额外添加了最大高度限制, 需要根据 alt 对数据进行预处理么? A: 是的, 需要根据 alt 对数组排序 Description The cows are going to space! They plan to achieve orbit by building a sort of space elevator: a giant tower of blocks. They have K (1 <= K <= 400) different types of blocks with w…