Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- #define int long long
- #define mod (int)(1e9+7)
- #define MAXI (int)(1e15+100)
- #define N 100005
- int power(int a,int m1)
- {
- if(m1==0)return 1;
- else if(m1==1)return a;
- else if(m1==2)return (1LL*a*a)%mod;
- else if(m1&1)return (1LL*a*power(power(a,m1/2),2))%mod;
- else return power(power(a,m1/2),2)%mod;
- }
- // Driver code to tes above functions
- int32_t main()
- {
- #ifndef ONLINE_JUDGE
- // for getting input from inpu.txt
- freopen("input.txt", "r", stdin);
- // for writing output to output.txt
- //freopen("output.txt", "w", sdtout);
- #endif
- ios_base::sync_with_stdio(0);
- cin.tie(NULL);
- cout.tie(NULL);
- string s;
- cin >> s;
- int pre[N];
- pre[0] = 0;
- pre[1] = 1;
- for(int i=2;i<N;i++)
- {
- if(i%3==0)
- pre[i] = ((2*pre[i-1])%mod - pre[i-2] + mod)%mod;
- else if(i%3==1)
- pre[i] = (pre[i-1] + pre[i-2])%mod;
- else
- pre[i] = ((2*pre[i-1])%mod + pre[i-2])%mod;
- }
- int n = s.size(), w=0,m=0;
- for(int i=0;i<n;i++)
- {
- if(s[i]=='w')
- w++;
- if(s[i]=='m')
- m++;
- }
- int ans = 1;
- if(w!=0 or m!=0)
- {
- cout << 0;
- return 0;
- }
- else
- {
- for(int i=0;i<n;i++)
- {
- if(s[i]=='n' or s[i]=='u')
- {
- int c = 0, j;
- for(j=i;j<n and s[j]==s[i];j++)
- c++;
- int k = pre[c];
- ans= (ans * k)%mod;
- i = j-1;
- }
- }
- }
- cout << ans;
- return 0;
- }
Add Comment
Please, Sign In to add comment