cf479E Riding in a Lift】的更多相关文章

E. Riding in a Lift time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Imagine that you are in a building that has exactly n floors. You can move between the floors in a lift. Let's number th…
题目链接: C. Riding in a Lift time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Imagine that you are in a building that has exactly n floors. You can move between the floors in a lift. Let's num…
C. Riding in a Lift Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/480/problem/C Description Imagine that you are in a building that has exactly n floors. You can move between the floors in a lift. Let's number the floors f…
E. Riding in a Lift time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Imagine that you are in a building that has exactly n floors. You can move between the floors in a lift. Let's number th…
题目链接:Codeforces 479E Riding in a Lift 题目大意:有一栋高N层的楼,有个无聊的人在A层,他喜欢玩电梯,每次会做电梯到另外一层.可是这栋楼里有个秘 密实验室在B层,所以每次他移动的时候就有了一个限制,x为当前所在层,y为目标层,|x - y| < |x - b|.问说移动K次 后,有多少不同的路径. 解题思路:dp[i][j]表示在第i步到达j层有多少种不同的路径,dis = abs(j-B) - 1,那么在[j-dis,j+dis]这个范围都能被转 移,除了j…
Riding in a Lift time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Imagine that you are in a building that has exactly n floors. You can move between the floors in a lift. Let's number the f…
Imagine that you are in a building that has exactly n floors. You can move between the floors in a lift. Let's number the floors from bottom to top with integers from 1 to n. Now you're on the floor number a. You are very bored, so you want to take t…
题意:给定n个楼层,初始在a层,b层不可停留,每次选一个楼层x,当|x-now| < |x-b| 且 x != now 时可达(now表示当前位置),此时记录下x到序列中,走k步,最后问有多少种可能的数的序列. 解法: 定义:      dp[i][j] 表示第i步在j楼的不同序列的个数 转移方程: 当j<b时, 那么dp[i][j] += dp[i-1][0~(j与b的中点(以下))] 当j>b时, 那么dp[i][j] += dp[i-1][(j与b的中点(以下))~n] 由于dp[…
题目链接:http://codeforces.com/contest/479/problem/E 题意:         给定一个启示的楼层a,有一个不能去的楼层b,对于你可以去的下一个楼层必须满足你当前楼层x与下一个要去的楼层y的距离小于x到b的距离.求出走k趟的方案数. 题解: dp[i][j]  表示第i趟 在第j层楼的方案数.一般用三个for才可以,所以我们用前缀和优化一下,时间复杂度降到O(n*k).空间复杂度有点大,所以我们可以用滚动数组. //#pragma comment(lin…
http://codeforces.com/problemset/problem/432/D 题目大意: 给出一栋n层的楼,初始在a层,b层不能去,每次走的距离必须小于当前位置到b的距离,问用电梯来回乱跑得到的序列有多少种. 思路:发现在a的这一侧永远不会到b的另一侧去,因此我们拆开来,只保留a所在的这边,dp: f[i][j]=Σf[i-1][j] (1<=j<=i+i-1) 然后我们记录前缀和,一边算出sum[1,i-1],另一边用两个指针l,r,每次r移动2,l移动1,算出sum[l,r…