wojiaocbj

cbj

May 2nd, 2022
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.00 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <math.h>
  4. #include <string.h>
  5. #include <ctype.h>
  6. #include <time.h>
  7. #pragma warning(disable:4996)
  8. typedef long long LL;
  9. typedef unsigned long long ULL;
  10. int arr[114514] = { 0 };
  11. int cmpi32(const void *p, const void *q){
  12.     int a = *(int *)p, b = *(int *)q;
  13.     if(a > b)return 1;
  14.     else if(a < b)return -1;
  15.     else return 0;
  16. }
  17. int main(){
  18. #ifdef _DEBUG
  19.     FILE *fp = freopen("../../../input.txt", "r", stdin);
  20.     //FILE *fp2 = freopen("../../../o5.txt", "w", stdout);
  21. #endif // _DEBUG
  22.     int n, i;
  23.     scanf("%d", &n);
  24.     for(i = 1; i <= n; i++){
  25.         scanf("%d", arr + i);
  26.     }
  27.     if(n == 1){
  28.         puts("1");
  29.         return 1;
  30.     }
  31.     qsort(arr + 1, n, sizeof(int), cmpi32);
  32.     int cnt = 0, ans = 0;
  33.     for(i = 1; i <= n + 1; i++){
  34.         if(arr[i] != arr[i - 1]){
  35.             ans += (cnt & 1);
  36.             cnt = 1;
  37.         }
  38.         else{
  39.             cnt += 1;
  40.         }
  41.     }
  42.     printf("%d\n", ans);
  43. #ifdef _DEBUG
  44.     freopen("CON", "r", stdin);
  45.     //freopen("CON", "w", stdout);
  46.     system("pause");
  47. #endif // _DEBUG
  48.     return 0;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment