其他分享
首页 > 其他分享> > codeforces Codeforces Round #597 (Div. 2) Constanze's Machine 斐波拉契数列的应用

codeforces Codeforces Round #597 (Div. 2) Constanze's Machine 斐波拉契数列的应用

作者:互联网

#include<bits/stdc++.h>
using namespace std;
char s[101010];
int dp[101010];
const int MOD = 1e9+7;
int main() {
    dp[0] = 1;
    scanf("%s", s+1);
    int N = strlen(s+1);
    for(int i=1; i<=N; ++i) {

        if(s[i] == 'm' || s[i] == 'w') {
            puts("0");
            return 0;
        }

        dp[i] = dp[i-1];
        if(i!=1&&(s[i] == 'n'&&s[i-1]=='n' || s[i]=='u'&&s[i-1]=='u'))
            dp[i] = (dp[i-2]+dp[i-1])%MOD;
    }
    printf("%d\n", dp[N]);
}
//斐波拉契数列应用

 

标签:597,int,Constanze,codeforces,Codeforces,char,101010,dp
来源: https://www.cnblogs.com/QingyuYYYYY/p/11784602.html