Codeforces 479E Riding in a Lift】的更多相关文章

题目链接: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…
题目链接: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…
题目链接:http://codeforces.com/problemset/problem/479/E 题意: 有一栋n层的房子. 还有一个无聊的人在玩电梯,每次玩电梯都会从某一层坐到另外一层. 他初始在a层,然后要玩k次电梯. 这栋楼里还有一个神秘实验室,在b层. 这让他每次坐电梯受到了限制: 当前在x层,然后要坐到y层,则必须满足|x-y|<|x-b| 问你共有多少种坐电梯的方案. 题解: 表示状态: dp[i][j] = numbers 表示当前在第i层,已经坐了j次电梯,此时的方案数.…
主题链接:点击打开链接 意甲冠军: 特定 n a b k 构造一个长度k该序列. 使得序列中 对于随意两个相邻的数 | w[i-1] - w[i] | < | w[i] - b | 且第一个数 |a - w[1] | < | w[1] - b | 问: 有多少种不同的序列. 思路:dp 对于粗暴的dp复杂度是 n^3 我们能够用前缀和来优化掉一维的dp.. 反正是简单粗暴的题.详细看代码吧.. #include <cstdio> #include <iostream>…
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…
题目链接: 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…
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…
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…
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…