fork(1) download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. int main() {
  4. int t;
  5. cin >> t;
  6. while (t--){
  7. int n;
  8. int a[n];
  9. cin >> n;
  10.  
  11. for (int i = 0; i < n; i++){
  12. cin >> a[i];
  13. }
  14. if (n == 1){
  15. cout << 1 << '\n';
  16. }
  17. else {
  18. sort (a, a+n);
  19. int brojac = 1;
  20. for (int i = 1; i < n; i++){
  21. if (a[i] != a[i-1]){
  22. brojac++;
  23. }
  24. }
  25. cout << brojac << '\n';
  26. }
  27. }
  28. return 0;
  29. }
Success #stdin #stdout 0.01s 5320KB
stdin
3
3
1 2 3
5
3 1 4 1 5
1
1
stdout
3
4
1