又是道简单题啊qwq,就是菜鸟题目读的慢了点qwq。
题意:在n个数中取出k个数,使得这k个数两两之间的差都是m的倍数。
对每个数%m,余数相同那么它们的差就是m的倍数辣~~~
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <cstdlib>
using namespace std;
int n,k,m,s,num,q[200200],a[200200],sum[200200];
int main()
{
scanf("%d%d%d",&n,&k,&m);
for(int i=1;i<=n;i++){scanf("%d",&a[i]);q[i]=a[i]%m;}
for(int i=1;i<=n;i++) sum[q[i]]++;
bool flag=false;
int i;
for(i=0;i<m;i++) if(sum[i]>=k){flag=true;break;}
if(flag){
puts("Yes");
num=i;
for(int i=1;i<=n;i++)
if(q[i]==num){
s++;
if(s==k){printf("%d\n",a[i]);break;}
else printf("%d ",a[i]);
}
}else puts("No");
return 0;
}