[Cpp] Description: calculate based on the formula given by the question. Hash weighting is not required at all. # include <cstdio >#include <cstring> char str [210]; int flag, count [15]; void bfs () {int len = strlen (str), n = 0, max = 0; for (int I = 0; I <len; I ++) if (str [I] <= 'Z' & str [I]> = 'A') {int j, c (0 ); for (j = I; j <len; j ++) if (str [j]> = 'A' & str [j] <= 'Z ') c = c * 32 + str [j]-'A' + 1; else break; I = j; if (! N | (n & max> c) max = c; count [n ++] = c;} while (1) {flag = 0; for (int I = 0; I <n-1; I ++) for (int j = I + 1; j <n; j ++) {int modi = (max/count [I]) % n; int modj = (max/count [j]) % n; if (modi = modj) {modi = (max/count [I] + 1) * count [I]; modj = (max/count [j] + 1) * count [j]; max = modi> modj? Modj: modi; flag = 1 ;}} if (! Flag) {printf ("% d \ n", max); return ;}} int main () {# ifndef ONLINE_JUDGE freopen ("a.txt", "r ", stdin); # endif while (gets (str) {puts (str); bfs ();} return 0 ;}