Saleh127

UVA 10338

Jun 24th, 2020
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define test int t; cin>>t; while (t--)
  4. #define ll long long int
  5. #define fellow_junior ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  6. int main()
  7. {
  8. fellow_junior
  9.  
  10. ll fact[21]={1};
  11. for(ll i=1;i<21;i++)
  12. {
  13. fact[i]=fact[i-1]*i;
  14. }
  15. ll n;
  16. cin>>n;
  17. for(ll i=1;i<=n;i++)
  18. {
  19. string a;
  20. cin>>a;
  21. ll l=a.size();
  22. ll c[26]={0};
  23. for(ll j=0;j<l;j++)
  24. {
  25. c[a[j]-65]++;
  26. }
  27. ll ans=fact[l];
  28. for(ll j=0;j<26;j++)
  29. {
  30. ans/=fact[c[j]];
  31. }
  32. cout<<"Data set "<<i<<": "<<ans<<endl;
  33. }
  34. return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment