Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cmath>
- #include <cstdio>
- #include <vector>
- #include <iostream>
- #include <algorithm>
- using namespace std;
- int main() {
- int n,i,k;
- cin>>n>>k;
- int arr[n];
- int rem[k]={0};
- for(i=0;i<n;i++)
- {
- cin>>arr[i];
- }
- for(i=0;i<n;i++)
- {
- rem[arr[i]%k]++;
- }
- int count = 0;
- for(i=1;i<=k/2;i++)
- {
- count = count + max(rem[i],rem[k-i]);
- }
- count = count + (rem[0]>0?1:0);
- if(k%2==0)
- {
- count = count - rem[k/2];
- if(rem[k/2]>0)
- count = count + 1;
- }
- cout<<count;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement