Submission
Status:
PPPPPPPPPP
Subtask/Task Score:
100/100
Score: 100
User: navysrimuang
Problemset: ดีกค์เวิร์ด
Language: cpp
Time: 0.003 second
Submitted On: 2026-01-16 14:45:44
#include<bits/stdc++.h>
using namespace std;
// A,Z = 65- 90
int n;
int ans = 0;
int ca,cb;
void think(int x,int y,int sum){
if(x + y > 2*n) return;
if(x == n && y == n){
ans += sum;
return;
}
if(x == y){
think(x+1,y,sum + ca*(x+y+1));
}else if(x > y){
if(x != n){
think(x+1,y,sum + ca*(x+y+1));
}
if(y!= n){
think(x,y+1,sum + cb*(x+y+1));
}
}
}
int main(){
cin >> n;
char a,b;
cin >> a >> b;
ca = (int)a - 64;
cb = (int)b - 64;
think(0,0,0);
cout << ans << "\n";
return 0;
}