Official

D - Send More Money Editorial by en_translator


When there are \(11\) or more kinds of alphabets, it is obviously UNSOLVABLE. We consider otherwise.

Rather than tackling the alphametic, it seems to be easier to implement to try all the assignment of digits to the alphabets exhaustively and check if it satisfies \(N_1+N_2=N_3\) for each assignment.

Since there are at most \(10!=3628800\) ways of assignments of digits, and given an assignment, we can check if it satisfies \(N_1+N_2=N_3\) with tens of arithmetic operations, so it is fast enough for time limit.

Note that we cannot assign \(0\) for the first alphabet of each string.

posted:
last update: