原题题目
代码实现(首刷自解)
int countVowelPermutation(int n){
long count1[5],count2[5];int i,j,count=1,mod = 1000000007;memset(count2,0,sizeof(count2));memset(count1,0,sizeof(count1));for(j=0;j<5;j++)count2[j] = 1;for(i=1;i<n;i++){
memcpy(count1,count2,sizeof(count2));memset(count2,0,sizeof(count2));count2[0] = (count1[1] + count1[2] + count1[4]) % mod;count2[1] = (count1[0] + count1[2] ) % mod;count2[2] = (count1[1] + count1[3] ) % mod;count2[3] = (count1[2]) % mod;count2[4] = (count1[2] + count1[3] ) % mod;}return (count2[0]+count2[1]+count2[2]+count2[3]+count2[4])%mod;
}