Advertisement
Guest User

Untitled

a guest
Feb 25th, 2017
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. #include <cmath>
  2. #include <cstdio>
  3. #include <vector>
  4. #include <iostream>
  5. #include <algorithm>
  6. using namespace std;
  7.  
  8.  
  9. int main() {
  10. int n,i,k;
  11. cin>>n>>k;
  12. int arr[n];
  13. int rem[k]={0};
  14. for(i=0;i<n;i++)
  15. {
  16. cin>>arr[i];
  17. }
  18. for(i=0;i<n;i++)
  19. {
  20. rem[arr[i]%k]++;
  21. }
  22. int count = 0;
  23. for(i=1;i<=k/2;i++)
  24. {
  25. count = count + max(rem[i],rem[k-i]);
  26. }
  27. count = count + (rem[0]>0?1:0);
  28. if(k%2==0)
  29. {
  30. count = count - rem[k/2];
  31. if(rem[k/2]>0)
  32. count = count + 1;
  33. }
  34. cout<<count;
  35. return 0;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement