Submission

Status:

PPPPPPPPPP

Subtask/Task Score:

100/100

Score: 100

User: krittaphot

Problemset: ดีกค์เวิร์ด

Language: cpp

Time: 0.003 second

Submitted On: 2026-03-04 12:57:04

#include <bits/stdc++.h>

using namespace std;
int n;
char f,s;
int v1;
int v2;
	
int solve(int first,int second,int sum){
//	cout << first << " " << second <<"\n";
	if(first < second){
		return 0;
	}
	if(first > n || second > n){
		return 0;
	}
	if(first + second == 2*n){
		return sum;
	}
	
	return solve(first+1,second,sum + v1*(first + second+1)) + solve(first,second+1,sum + v2*(first + second+1));
	
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> f >> s;
	v1 = f-'A'+1;
	v2 = s-'A'+1;
//	cout << v1 << " " << v2;
	 	
	cout << solve(0,0,0);
}