<output id="qn6qe"></output>

    1. <output id="qn6qe"><tt id="qn6qe"></tt></output>
    2. <strike id="qn6qe"></strike>

      亚洲 日本 欧洲 欧美 视频,日韩中文字幕有码av,一本一道av中文字幕无码,国产线播放免费人成视频播放,人妻少妇偷人无码视频,日夜啪啪一区二区三区,国产尤物精品自在拍视频首页,久热这里只有精品12

      Codeforces Round #597 (Div. 2) C. Constanze's Machine dp

      C. Constanze's Machine

      Constanze is the smartest girl in her village but she has bad eyesight.

      One day, she was able to invent an incredible machine! When you pronounce letters, the machine will inscribe them onto a piece of paper. For example, if you pronounce 'c', 'o', 'd', and 'e' in that order, then the machine will inscribe "code" onto the paper. Thanks to this machine, she can finally write messages without using her glasses.

      However, her dumb friend Akko decided to play a prank on her. Akko tinkered with the machine so that if you pronounce 'w', it will inscribe "uu" instead of "w", and if you pronounce 'm', it will inscribe "nn" instead of "m"! Since Constanze had bad eyesight, she was not able to realize what Akko did.

      The rest of the letters behave the same as before: if you pronounce any letter besides 'w' and 'm', the machine will just inscribe it onto a piece of paper.

      The next day, I received a letter in my mailbox. I can't understand it so I think it's either just some gibberish from Akko, or Constanze made it using her machine. But since I know what Akko did, I can just list down all possible strings that Constanze's machine would have turned into the message I got and see if anything makes sense.

      But I need to know how much paper I will need, and that's why I'm asking you for help. Tell me the number of strings that Constanze's machine would've turned into the message I got.

      But since this number can be quite large, tell me instead its remainder when divided by 109+7.

      If there are no strings that Constanze's machine would've turned into the message I got, then print 0.

      Input

      Input consists of a single line containing a string s (1≤|s|≤105) — the received message. s contains only lowercase Latin letters.

      Output

      Print a single integer — the number of strings that Constanze's machine would've turned into the message s, modulo 109+7.

      Examples

      input
      ouuokarinn
      output
      4
      input
      banana
      output
      1
      input
      nnn
      output
      3
      input
      amanda
      output
      0

      Note

      For the first example, the candidate strings are the following: "ouuokarinn", "ouuokarim", "owokarim", and "owokarinn".

      For the second example, there is only one: "banana".

      For the third example, the candidate strings are the following: "nm", "mn" and "nnn".

      For the last example, there are no candidate strings that the machine can turn into "amanda", since the machine won't inscribe 'm'.

      題意

      現在有個機器,會把w翻譯成uu,把m翻譯成nn。

      現在給你一個字符串,讓你還原成原來的樣子,問你有多少種還原方式。

      另外:如果字符串種存在w或者m,輸出-1

      題解

      dp,兩種轉移,保持不變和變w/變m,轉移即可。

      代碼

      #include<bits/stdc++.h>
      using namespace std;
      const int mod = 1e9+7;
      const int maxn = 1e5+7;
      string s;
      int dp[maxn];
      int flag = 0;
      int main(){
      	cin>>s;
      	int flag = 0;
      	dp[0]=1;
      	if(s[0]=='m'||s[0]=='w')flag = 1;
      	for(int i=1;i<s.size();i++){
      		dp[i]=dp[i-1];
      		if(s[i]=='m'||s[i]=='w')flag = 1;
      		if((s[i]=='u'&&s[i-1]=='u')||(s[i]=='n'&&s[i-1]=='n')){
      			if(i==1){
      				dp[i]=(dp[i]+1)%mod;
      			}else{
      				dp[i]=(dp[i]+dp[i-2])%mod;
      			}
      		}
      	}
      	if(flag==1){
      		cout<<"0"<<endl;
      	}else{
      		cout<<dp[s.size()-1]%mod<<endl;
      	}
      }
      
      posted @ 2019-11-02 22:20  qscqesze  閱讀(435)  評論(0)    收藏  舉報
      主站蜘蛛池模板: 91中文字幕一区在线| 强奷漂亮人妻系列老师| 精品无码一区二区三区爱欲 | 亚洲av永久一区二区| 国产乱老熟女乱老熟女视频| 久久精品国产久精国产| 国产精品理论片| 亚洲精品成a人在线观看| 自拍偷自拍亚洲精品情侣| 亚洲免费福利在线视频| 精品国产迷系列在线观看| 中文字幕亚洲综合久久蜜桃| 久久精品国产99久久久古代 | 亚洲中文字幕无码日韩精品| 亚洲成人av在线综合| 亚洲av永久无码天堂影院| free性开放小少妇| 久久国产精品不只是精品| 国产99re热这里只有精品| 动漫AV纯肉无码AV电影网| 久久亚洲精品人成综合网| 亚洲欧美日韩成人综合一区| 国产免费毛卡片| 亚洲国产成人va在线观看天堂| 自拍视频亚洲精品在线| 亚洲成a人片在线视频| 国产精品美女久久久久久麻豆| 日韩乱码人妻无码中文字幕视频| 鲁丝一区二区三区免费| 饶平县| 精品国产污污免费网站入口| 中文字幕国产精品二区| 国产自在自线午夜精品| 2018年亚洲欧美在线v| 亚洲第三十四九中文字幕| 99久久亚洲综合精品成人网| 免费国产好深啊好涨好硬视频| 亚洲av与日韩av在线| 人妻被猛烈进入中文字幕| 精品不卡一区二区三区| 四虎库影成人在线播放|