fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. #define int long long
  5. const int MOD = (int)1e9+7;
  6. int cnt[101],ans;
  7.  
  8. int32_t main() {
  9. int t; cin >> t;
  10. while(t--){
  11. fill(cnt,cnt+101,0); ans=1;
  12. int n; cin >> n;
  13. while(n--){
  14. int x; cin >> x;
  15. cnt[x]++;
  16. if(cnt[x]==2)ans=0;
  17. }
  18. for(int i = 1; i <= 100; i++)
  19. for(int j = i+1; j<= 100; j++)
  20. if(cnt[i] and cnt[j]) ans*=((cnt[i]*cnt[j])%MOD)*(j-i), ans%=MOD;
  21. cout << ans << "\n";
  22. }
  23. }
  24.  
Success #stdin #stdout 0s 5316KB
stdin
3
4
2 3 4 1
5
70 78 80 82 81
8
100 99 98 97 96 95 94 93
stdout
12
506880
411327125