Advertisement
LEGEND2004

Coxluq

Feb 5th, 2024
945
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.54 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. #define int long long
  5. const int N = 1e5 + 5;
  6. int a[N] , cnt[N];
  7.  
  8. signed main()
  9. {
  10.     ios_base::sync_with_stdio(0);
  11.     cin.tie(0);
  12.  
  13.     int n , k;
  14.     cin >> n >> k;
  15.     for(int i = 0; i < n; i++){
  16.         cin >> a[i];
  17.         a[i] %= k;
  18.         cnt[a[i]]++;
  19.     }
  20.     int ans = 0;
  21.     for(int i = 1; (i + i) < k; i++){
  22.         ans += max(cnt[i] , cnt[k - i]);
  23.     }
  24.     if(cnt[0] > 0)
  25.         ans++;
  26.     if(k % 2 == 0 && cnt[k / 2] > 0)
  27.         ans++;
  28.     cout << ans << '\n';
  29. }
  30.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement