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

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

zoj 3791 An Easy Game

發布時間:2024/6/18 编程问答 50 豆豆
生活随笔 收集整理的這篇文章主要介紹了 zoj 3791 An Easy Game 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3791

題目大意:給你兩個長度為n的01串,第一個為起始串,另一個為目標串。給你k次操作,每次選擇起始串的m個不同的位置取反(0變1,1變0),問k次操作以后有多少種方案能使得起始串變成目標串。

dp[i][j]表示第i步后有就j個不匹配的步數。

1 #include <cstdio> 2 #include <cstring> 3 #include <algorithm> 4 #define ll long long 5 #define maxn 200 6 using namespace std; 7 const int mod=1e9+9; 8 9 ll c[maxn][maxn],dp[maxn][maxn]; 10 int n,k,m; 11 char str1[maxn],str2[maxn]; 12 13 void get() 14 { 15 for(int i=0; i<maxn; i++) c[i][0]=1; 16 for(int i=1; i<maxn; i++) 17 { 18 for(int j=1; j<=i; j++) 19 { 20 c[i][j]=(c[i-1][j-1]+c[i-1][j])%mod; 21 } 22 } 23 } 24 25 int main() 26 { 27 get(); 28 while(scanf("%d%d%d",&n,&k,&m)!=EOF) 29 { 30 scanf("%s",str1); 31 scanf("%s",str2); 32 int cnt=0; 33 for(int i=0; i<n; i++) 34 { 35 if(str1[i]!=str2[i]) cnt++; 36 } 37 memset(dp,0,sizeof(dp)); 38 dp[0][cnt]=1; 39 for(int i=0; i<k; i++) 40 { 41 for(int j=0; j<=n; j++) 42 { 43 for(int x=0; x<=m; x++) 44 { 45 if(j+m-2*x<0) break; 46 if(j+m-2*x>n) continue; 47 dp[i+1][j+m-2*x]=(dp[i+1][j+m-2*x]%mod+c[j][x]*c[n-j][m-x]%mod*dp[i][j]%mod)%mod; 48 } 49 } 50 } 51 printf("%lld\n",dp[k][0]); 52 } 53 return 0; 54 } View Code

?

轉載于:https://www.cnblogs.com/fanminghui/p/3801290.html

總結

以上是生活随笔為你收集整理的zoj 3791 An Easy Game的全部內容,希望文章能夠幫你解決所遇到的問題。

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