链接:牛客网NC57
题意、输入、输出:
分析:dp,六
思路:dp
代码:
import java.util.*;
public class Solution {
/**
* 好多牛牛
* @param s string字符串
* @return int整型
*/
static int mod=(int)1e9+7;
public int solve (String s) {
// write code here
long[][] dp=new long[6][s.length()];
char[] cs=s.toCharArray();
char[] hh=new char[]{'n','i','u','n','i','u'};
if(cs[0]=='n')dp[0][0]++;
for(int i=1;i<s.length();i++){
for(int j=0;j<6;j++){
if(j==0)dp[j][i]=dp[j][i-1]+(cs[i]==hh[j]?1:0);
else dp[j][i]=dp[j][i-1]+(cs[i]==hh[j]?dp[j-1][i-1]:0);
dp[j][i]%=mod;
}
}
return (int)dp[5][s.length()-1];
}
}