Question: calculate the number of different strings in a string's letter set.
Analysis: Combination and count. Find the full arrangement of all letters, and divide them by the internal repetition of each letter.
Note: (⊙ _ ⊙)
# Include <iostream> # include <cstdlib> # include <cstring> # include <cstdio> using namespace STD; int Times [26]; char STR [25]; long ans; long long FAC (int n) {long value = 1ll; For (int K = 2; k <= N; ++ K) value * = K; return value ;} int main () {int N, Len; while (~ Scanf ("% d", & N) for (int t = 1; t <= N; ++ t) {scanf ("% s", STR ); len = strlen (STR); For (Int J = 0; j <26; ++ J) Times [J] = 0; ans = FAC (LEN ); for (Int J = 0; j <Len; ++ J) Times [STR [J]-'a'] ++; For (Int J = 0; j <26; ++ J) if (Times [J]> 0) ans/= FAC (Times [J]); printf ("Data Set % d: % LLD \ n", T, ans);} return 0 ;}
Ultraviolet A 10338-mischievous children