比赛 |
2025.4.12 |
评测结果 |
AAAAAAAAAAAAAAAAAAAAAAAAA |
题目名称 |
Moo Decomposition |
最终得分 |
100 |
用户昵称 |
徐诗畅 |
运行时间 |
1.388 s |
代码语言 |
C++ |
内存使用 |
19.85 MiB |
提交时间 |
2025-04-12 10:19:45 |
显示代码纯文本
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int mod=1e9+7,N=1e6+5;
int k,n,l,fac[N],inv[N];
string s;
int c(int x,int y){return fac[x]*inv[y]%mod*inv[x-y]%mod;}
int qpow(int x,int y){
int res=1;
while(y){
if(y&1) res=res*x%mod;
x=x*x%mod;
y>>=1;
}
return res;
}
signed main(){
freopen("Moo.in","r",stdin);
freopen("Moo.out","w",stdout);
fac[0]=1;
for(int i = 1;i<=1e6;i++) fac[i]=fac[i-1]*i%mod;
inv[1000000]=qpow(fac[1000000],mod-2);
for(int i = 1e6-1;i>=0;i--)
inv[i]=inv[i+1]*(i+1)%mod;
scanf("%lld%lld%lld",&k,&n,&l);
cin>>s; int num=0,ans=1;
for(int i = s.size()-1;i>=0;i--){
if(s[i]=='O') num++;
else ans=ans*c(num,k)%mod,num-=k;
}
printf("%lld",qpow(ans,l));
return 0;
}