URAL1017. Staircases】的更多相关文章

链接 简单递推 #include <iostream> #include<cstdio> #include<cstring> #include<algorithm> #include<stdlib.h> using namespace std; #define LL long long LL dp[][]; int main() { int i,j,n,g; LL ans=; scanf("%d",&n); ; i &…
题目传送门 /* 题意:给n块砖头,问能组成多少个楼梯,楼梯至少两层,且每层至少一块砖头,层与层之间数目不能相等! 递推DP:dp[i][j] 表示总共i块砖头,最后一列的砖头数是j块的方案数 状态转移方程:dp[i][j] += dp[i-j][k] 表示最后一列是j,那么上一个状态是少了最后一列 总共i-j块砖头,倒数第二列是k块砖头.k<j, j<=i 最后累加dp[n][i], i<n因为最少要两层 dp[0][0] = 1; 还有更简单的做法,没看懂:http://m.blog…
One curious child has a set of N little bricks. From these bricks he builds different staircases. Staircase consists of steps of different sizes in a strictly descending order. It is not allowed for staircase to have steps equal sizes. Every staircas…
题目链接:http://codeforces.com/problemset/problem/362/B 题目意思:给出整数n和m,表示有n级楼梯和m级dirty的楼梯,接下来m个数表示对应是哪一个数字的楼梯是dirty的楼梯,不一定是按小到大给定的,需要判断的是,在只可以走一级.二级或三级的情况,是否可以把所有的非dirty楼梯走完.当然,如果dirty的楼梯中包含第一级(初始位置)或者最后一级(最终位置),那么默认是不能走完非dirty楼梯的. 由于给定的dirty楼梯的数字是任意无序的,所以…
题意:一个小男孩要上楼梯,他一次可以走1个台阶或2个台阶或3个台阶,但是有一些台阶是脏的,他不想走在脏台阶上.一共有n个台阶和m个脏台阶,他最开始在第1个台阶上,要走到第n个台阶.问小男孩能不能不踩到脏台阶的前提下走到n个台阶. 思路:对于给定的m个脏序列,先排序后,没有连续的三个数就行. #include<cstdio> #include<cstring> #include<algorithm> #include<iostream> #include<…
http://codeforces.com/contest/362/problem/B 先排序,然后判断第一个和最后一个是不是脏的,如果是则输出NO,然后判断其中三个脏的是不是连着的,如果是也输出NO,否则输出YES #include <cstdio> #include <cstring> #include <algorithm> #define LL __int64 #define maxn 100010 using namespace std; LL a[maxn]…
http://acm.timus.ru/problem.aspx?space=1&num=1017 #include <cstdio> #include <cstring> #include <algorithm> #define maxn 600 using namespace std; __int64 dp[maxn][maxn]; int main() { int n; scanf("%d",&n); memset(dp,,si…
http://acm.timus.ru/problem.aspx?space=1&num=1017 题意:有n块砖,要求按照严格递增的个数摆放成楼梯,求楼梯的摆放种类数. 思路:状态转移方程:dp[i][j]=sum(dp[i-j][k]), 0 < k < j; i 表示砖的总数,j表示最高的那层的个数. #include <stdio.h> #include <string.h> #define LL long long ; LL dp[N][N]; int…
dp[i][j]表示i个砖头构成的最高台阶不高于j的楼梯数目 Accepted 1163 C++11 0 2280 #include "bits/stdc++.h" using namespace std; typedef long long LL; + ; LL dp[MAXN][MAXN]; void init() { ; i < MAXN; i++) { dp[][i] = ; } ; i < MAXN; i++) { ; j <= i; j++) { dp[i…
acm之pku题目分类 对ACM有兴趣的同学们可以看看 DP:  1011   NTA                 简单题  1013   Great Equipment     简单题  1024   Calendar Game       简单题  1027   Human Gene Functions   简单题  1037   Gridland            简单题  1052   Algernon s Noxious Emissions 简单题  1409   Commun…