比赛 26暑假集训模拟赛3 评测结果 AAAAAAAAAAAAAAAAAAAAAAAAA
题目名称 Moo Decomposition 最终得分 100
用户昵称 VTXE 运行时间 3.854 s
代码语言 C++ 内存使用 19.47 MiB
提交时间 2026-07-06 08:58:34
显示代码纯文本
#include <bits/stdc++.h>
using namespace std;
#define ll long long

const ll mod=1e9+7;

ll k,n,l;
string s;
ll fac[1100000],inv[1100000];
ll cnt,ans=1;

ll mpow(ll aa,ll bb){
	ll res=1;
	while (bb){
		if (bb&1) res=(res*aa)%mod;
		aa=(aa*aa)%mod;
		bb>>=1;
	}
	return res;
}

void init(){
	fac[0]=fac[1]=1;
	for (int i=2;i<=1000010;i++){
		fac[i]=fac[i-1]*i%mod;
	}
	for (int i=0;i<=1000010;i++){
		inv[i]=mpow(fac[i],mod-2);
	}
}

ll C(ll a,ll b){
	return fac[a]*inv[a-b]%mod*inv[b]%mod;
}

int main(){
	freopen("Moo.in","r",stdin);
	freopen("Moo.out","w",stdout);
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	cin>>k>>n>>l;
	cin>>s;
	s=" "+s;
	init();
	for (int i=n;i>=1;i--){
		if (s[i]=='O'){
			cnt++;
		}else{
			ans=ans*C(cnt,k)%mod;
			cnt-=k;
		}
	}
	cout<<mpow(ans,l);
	return 0;
}