AhmedAshraff

Untitled

Nov 23rd, 2024
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.88 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. #define boAshraf ios_base::sync_with_stdio(false); cin.tie(NULL);
  3. #define ll long long
  4. #define sz(s) (int)(s).size()
  5. #define all(s) (s).begin(),(s).end()
  6. using namespace std;
  7. void File();
  8. void sol();
  9. const int mod=7901;
  10. int mul(int a,int b){
  11.     return a*b%mod;
  12. }
  13. const int N=1001;
  14. int fact[N];
  15. void pre(){
  16.     fact[0]=1;
  17.     for(int i=1;i<N;i++)fact[i]=mul(i,fact[i-1]);
  18. }
  19. int main() {
  20.     boAshraf
  21.     File();
  22.     pre();
  23.     int t = 1;
  24.     cin >> t;
  25.     while (t--) {
  26.         sol();
  27.     }
  28.     return 0;
  29. }
  30.  
  31. void sol() {
  32.     int ans=1;
  33.     int n;
  34.     cin>>n;
  35.     map<int,int>mp;
  36.     for(int i=0;i<n;i++){
  37.         int x;cin>>x;mp[x]++;
  38.     }
  39.     for(auto [f,s]:mp)ans=mul(ans,fact[s]);
  40.     cout<<ans<<'\n';
  41. }
  42.  
  43. void File() {
  44. #ifndef ONLINE_JUDGE
  45.     freopen("input.txt", "r", stdin);
  46.     freopen("output.txt", "w", stdout);
  47. #endif
  48. }
Advertisement
Add Comment
Please, Sign In to add comment