Problem B
GREAT + SWERC = PORTO
We want to have a great SWERC at Porto this year and we
approached this challenge in several ways. We even framed it as
a word addition problem, similar to the classic
![\includegraphics[width=0.35\textwidth ]{greatSwercPic.png}](/problems/greatswercporto/file/statement/en/img-0001.png)
To solve this word addition problem we had to find positive
digits for G, S and P, and digits for R, E, A, T, W, C, O, so
that each letter has a different digit and the sum is correct.
It turns out that, unlike the classical
Having more than one solution does not make
Task
Given a word addition problem, compute the number of solutions (possibly zero).
Input
A line with an integer
Constraints
Each word has at most 10 symbols (capital letters).
A word problem has at most 10 distinct letters.
Output
A single line with an integer: the number of solutions of the word addition problem given as input.
Sample Input 1 | Sample Output 1 |
---|---|
3 GREAT SWERC PORTO |
6 |
Sample Input 2 | Sample Output 2 |
---|---|
3 SEND MORE MONEY |
1 |
Sample Input 3 | Sample Output 3 |
---|---|
5 TOO GOOD TO BE TRUE |
93 |