fork download
  1. // بسم الله الرحمن الرحيم
  2. //______________________________________________________________________________________________________________________
  3. // ooooooooooooo oooo .o8 .o8
  4. // 8' 888 `8 `888 "888 "888
  5. // 888 .oooo. 888 .oo. 888oooo. .ooooo. oooo oooo 888oooo.
  6. // 888 `P )88b 888P"Y88b d88' `88b d88' `88b `888 `888 d88' `88b
  7. // 888 .oP"888 888 888 888 888 888 888 888 888 888 888
  8. // 888 d8( 888 888 888 888 888 888 888 888 888 888 888
  9. // o888o `Y888""8o o888o o888o `Y8bod8P' `Y8bod8P' `V88V"V8P' `Y8bod8P'
  10. //______________________________________________________________________________________________________________________
  11. // #
  12. // #@@
  13. // @@@
  14. // @@
  15. // @@
  16. // @# @ @@@& @@
  17. // @ @@ @@@@@ @@@ @* @@ @@ /@@@@@@@@@
  18. // %@ @& @@ @@ @@* ,@ @# @@@( @@
  19. // @@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  20. // &@ @@ #@&
  21. // @@ @. @@@ @@ ,@@. @/
  22. // ,@@@ @@@@@@@( ,@@@ @@@@
  23. //______________________________________________________________________________________________________________________
  24. /*
  25.  *
  26. */
  27. //----------------------------------------------------------------------------------------------------------------------
  28. #ifdef ONLINE_JUDGE
  29. #pragma GCC optimize("O3,unroll-loops")
  30. #pragma GCC target("avx2")
  31. #endif
  32.  
  33. #include <bits/stdc++.h>
  34.  
  35. #define eb emplace_back
  36. #define mp make_pair
  37. using ll = long long;
  38. using ld = long double;
  39. int const MOD = 1000000007;
  40. using namespace std;
  41.  
  42. int modpow(ll x, ll y);
  43.  
  44. vector<ll> primeFactors(ll n);
  45.  
  46. template<typename It>
  47. ll gcdi(It s, It e) {
  48. ll o = 0;
  49. for (It i = s; i != e; ++i) { o = gcd(o, *i); }
  50. return o;
  51. }
  52.  
  53. template<typename It>
  54. ll lcmi(It s, It e) {
  55. ll o = 1;
  56. for (It i = s; i != e; ++i) { o = lcm(o, *i); }
  57. return o;
  58. }
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.  
  75.  
  76.  
  77.  
  78.  
  79.  
  80.  
  81.  
  82.  
  83.  
  84.  
  85.  
  86.  
  87.  
  88.  
  89.  
  90.  
  91.  
  92.  
  93.  
  94.  
  95.  
  96.  
  97.  
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117. void solve() {
  118. int n;
  119. cin >> n;
  120. if (n <= 2) {
  121. cout << "0\n";
  122. return;
  123. }
  124. int arr[n];
  125. int freq[200];
  126. for (int &i : freq)
  127. i = 0;
  128. for (int i = 0; i < n; i++) {
  129. cin >> arr[i];
  130. freq[arr[i]]++;
  131. // cout << freq[arr[i]] << ' ';
  132. }
  133. // cout << '\n';
  134. int ans = 0;
  135. for (int i : freq) {
  136. if (i > 2)
  137. ans++;
  138. // cout << i << ' ';
  139. }
  140. cout << ans << '\n';
  141. return;
  142. }
  143.  
  144.  
  145.  
  146.  
  147.  
  148.  
  149.  
  150.  
  151.  
  152.  
  153.  
  154.  
  155.  
  156.  
  157.  
  158.  
  159.  
  160.  
  161.  
  162.  
  163.  
  164.  
  165.  
  166.  
  167.  
  168.  
  169.  
  170.  
  171.  
  172.  
  173.  
  174.  
  175.  
  176.  
  177.  
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.  
  196.  
  197.  
  198.  
  199.  
  200.  
  201. int main() {
  202. ios::sync_with_stdio(false);
  203. cin.tie(nullptr);
  204. int t;
  205. cin >> t;
  206. while (t--) {
  207. solve();
  208. }
  209. return 0;
  210. }
  211.  
  212.  
  213. int modpow(ll x, ll y) {
  214. ll res = 1;
  215. x %= MOD;
  216. if (x == 0) return 0;
  217. while (y > 0) {
  218. if (y & 1) res = (res * x) % MOD;
  219. y = y >> 1;
  220. x = (x * x) % MOD;
  221. }
  222. return (int) res;
  223. }
  224.  
  225. vector<ll> primeFactors(ll n) {
  226. vector<ll> f;
  227. while (n % 2 == 0) {
  228. f.eb(2);
  229. n /= 2;
  230. }
  231. for (ll i = 3; i <= (ll) sqrt((double) n); i += 2) {
  232. while (n % i == 0) {
  233. f.eb(i);
  234. n /= i;
  235. }
  236. }
  237. if (n > 2) {
  238. f.eb(n);
  239. }
  240. return f;
  241. }
  242.  
Success #stdin #stdout 0.01s 5304KB
stdin
4
1
1
2
1 1
6
2 2 3 3 3 3
9
4 2 2 2 2 4 2 4 4
stdout
0
0
0
0