Submission
Status:
PPPPPPPPPP
Subtask/Task Score:
100/100
Score: 100
User: mmpk
Problemset: ดีกค์เวิร์ด
Language: cpp
Time: 0.004 second
Submitted On: 2025-10-04 21:20:01
#include<bits/stdc++.h>
using namespace std;
int n,a,b;long long ans;
void f(int p,int o,long long w){
if(p>2*n){
if(!o)ans+=w;
return;
}
if(o<n)f(p+1,o+1,w+1LL*a*p);
if(o>0)f(p+1,o-1,w+1LL*b*p);
}
int main(){
char x,y;cin>>n>>x>>y;a=x-'A'+1;b=y-'A'+1;f(1,0,0);
cout<<ans;
}