用同余加桶排 如果有一个桶里的数大于等于k就输出Yes和前k个数 没有就输出No
#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
#define ll long long
#define mem(a, b) memset(a, b, sizeof(a))
#define debug() puts("F*** you everyday!");
#define Maxn 100005
struct node {
int num, mod;
}str[Maxn];
int main()
{
int n, m, k, x, a[Maxn];
mem(a, 0);
scanf("%d%d%d", &n, &k, &m);
for (int i = 0; i < n; i ++) {
scanf("%d", &str[i].num);
str[i].mod = str[i].num % m;
a[str[i].mod] ++;
}
int u = 0;
for (int i = 0; i < m; i ++) {
if (a[i] >= k) {
u = 1;
printf("Yes\n");
for (int j = 0; j < n && k; j ++) {
if (str[j].mod == i) {
printf("%d ", str[j].num);
k --;
}
}
break;
}
}
if (u) {
printf("\n");
}
else {
printf("No\n");
}
}