Ultraviolet A 10338-mischievous children

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.