日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

codeforces 909C. Python Indentation

發布時間:2023/12/18 python 30 豆豆
生活随笔 收集整理的這篇文章主要介紹了 codeforces 909C. Python Indentation 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

動態規劃的題目

狀態轉移方程參考https://www.cnblogs.com/Leohh/p/8135525.html

#include<cstdio> #include<cstdlib> #include<cstring> #include<iostream> #include<algorithm> #include<string> #include<vector> #define DEBUG(x) cout<<#x<<" = "<<x<<endl using namespace std; const int MAXN=5e3+10; const int MOD=1e9+7; ///第i個表達式縮進j個單位,有多少種結果 int dp[MAXN][MAXN]; char prg[MAXN]; int main() { // freopen("in.txt","r",stdin);int n;scanf("%d\n",&n);for(int i=1;i<=n ;i++ ){scanf("%c\n",&prg[i]);}dp[1][0]=1;for(int i=2;i<=n ;i++ ){///第i行縮進不超過i-1個單位if(prg[i-1]=='f'){dp[i][0]=0;for(int j=1;j<=i-1 ;j++ ){dp[i][j]=dp[i-1][j-1]%MOD;}}else {///從右往左,累計求和for(int j=i-2;j>=0 ;j-- ){dp[i][j]=(dp[i][j+1]%MOD+dp[i-1][j]%MOD)%MOD;}}}int ans=0;if(prg[n]=='s')for(int i=0;i<=n-1 ;i++ ){ans=(ans+dp[n][i])%MOD;}printf("%d\n",ans); }

?

轉載于:https://www.cnblogs.com/MalcolmMeng/p/9941990.html

總結

以上是生活随笔為你收集整理的codeforces 909C. Python Indentation的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。