Advertisement
Guest User

Untitled

a guest
May 26th, 2018
750
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.52 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. typedef long long ll;
  5. const int N = 1010 , mod = 7901;
  6.  
  7. int n , x[N] , cnt[N] , fact[N];
  8.  
  9. int main(){
  10.  
  11. fact[0]=1;
  12. for(int i=1;i<N;i++)
  13.     fact[i]=fact[i-1]*i%mod;
  14.  
  15. int t;
  16. cin>>t;
  17. while( t-- ){
  18.  
  19.     cin>>n;
  20.     for(int i=0;i<n;i++){
  21.         cin>>x[i];
  22.         cnt[x[i]]++;
  23.     }
  24.  
  25.     int ans=1;
  26.     for(int i=1;i<N;i++)
  27.         ans = ans * fact[cnt[i]] %mod;
  28.  
  29.     cout<<ans<<endl;
  30.  
  31.     for(int i=0;i<n;i++)
  32.         cnt[x[i]]--;
  33. }
  34.  
  35.  
  36. return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement