// UVa 10338 - Mischievous Children #include <iostream> #include <string> #include <string.h> using namespace std; #define integer unsigned long long int main() { integer f[21]; f[0] = 1; for (int i = 1; i <= 20; i++) f[i] = f[i - 1] * i; int tt; cin >> tt; for (int t = 1; t <= tt; t++) { string word; cin >> word; int c[26]; memset(c, 0, sizeof(c)); for (int i = 0; i < word.length(); i++) c[word[i] - 'A']++; integer sol = f[word.length()]; for (int ch = 0; ch < 26; ch++) sol /= f[c[ch]]; cout << "Data set " << t << ": " << sol << endl; } return 0; }
No comments:
Post a Comment