直接采用二维数组模拟实现
#include <iostream>
using namespace std;
const int N = 100;
int arr[N][N];
int point[N];//计数int main()
{int m, n,data;cin >> m >> n;for (int i = 0; i < n; i++){cin >> data;int key = data % m;arr[key][point[key]] = data;point[key]++;}cin >> data;int pos = data % m;int flag = 0;int cnt = 0;for (int i = 0; i < point[pos]; i++){cnt++;if (arr[pos][i] == data){flag = 1;}}if (flag)cout << pos << ',' << cnt-1;else cout << -1;return 0;
}