cf 495人题 简单dp
2018-01-19 00:06
411 查看
就是python的语法,for之后一定要缩进,给出for或者statement的顺序,问你代码形式有多少种.
期末血炸,心态崩了,希望可以好好做题.做一个废物真的好痛苦啊
/* Farewell. */ #include <iostream> #include <vector> #include <cstdio> #include <stack> #include <cstring> #include <algorithm> #include <queue> #include <map> #include <string> #include <cmath> #include <bitset> #include <iomanip> #include <set> using namespace std; #define lson lmrt<<1 #define rson m+1rrt<<1|1 #define MP make_pair #define MT make_tuple #define PB push_back #define gcd __gcd #define debug(x) std::cerr << #x << " = " << (x) << std::endl typedef long long LL; typedef unsigned long long ULL; typedef pair<int,int > pii; typedef pair<LL,LL> pll; typedef pair<double,double > pdd; typedef pair<double,int > pdi; const int INF = 0x7fffffff; const LL INFF = 0x7f7f7f7fffffffff; const int MAXM = 5e3+17; const int MOD = 1e9+7; const int MAXN = 5e3+17; int dp[MAXN][MAXN]; char cmd[MAXN]; int main(int argc ,char const *argv[]) { #ifdef GoodbyeMonkeyKing freopen("Input.txt","r",stdin);freopen("Output.txt","w",stdout); #endif int n; cin>>n; for (int i = 0; i < n; ++i) cin>>cmd[i]; dp[0][0] = 1; for (int i = 1; i < n; ++i) { if(cmd[i-1]=='f') for (int j = 0; j < n; ++j) dp[i][j+1] = dp[i-1][j]; else { int sum = 0; for (int j = n-1; j > -1; --j) { dp[i][j] = (sum+dp[i-1][j])%MOD; sum=(dp[i-1][j]+sum)%MOD; } } } int ans = 0; for (int i = 0; i <= n; ++i) ans=(dp[n-1][i]+ans)%MOD; cout<<ans<<endl; return 0; }
期末血炸,心态崩了,希望可以好好做题.做一个废物真的好痛苦啊
相关文章推荐
- CF 191A - Dynasty Puzzles(简单DP)
- CF 148D Bag of mice 概率dp 简单题
- CF 467C - George and Job (简单区间DP)
- 简单dp之递推(1)--CF 429B B.Working out
- (CF 148D Bag of mice)<简单概率DP>
- CF 445A 简单DP
- cf 429B Working out(简单dp)
- Paths through the Hourglass UVA - 10564 简单dp (码力)
- hdu 5092 Seam Carving (简单数塔DP,题没读懂,,不过可以分析样例)
- CF D. Beautiful numbers (数位dp)
- HDU6060-RXD and dividing 简单树形DP+贪心
- hdu 4714 Tree2cycle(简单图或树DP,4级)
- 树形DP(简单题)(Y HDU4705)
- hdu 2501 Tiling_easy version(简单dp)
- hdu 1297 Children’s Queue(java+简单dp)
- UVaLive 3530 - Martian Mining (简单DP)
- hdu 4504 威威猫系列故事——篮球梦_简单dp
- 简单概率dp(期望)-zoj-3640-Help Me Escape
- 01背包(简单dp) HDU 1203 I need Offer
- poj1163 简单的dp