voidsolve(){ int _; cin >> _; for (int tc = 0; tc < _; ++tc) { int n, k, cnt[101] = {}; cin >> n >> k; for (int i = 0; i < n; ++i) { int tmp; cin >> tmp; ++cnt[tmp]; }
int tot = 0; while (true) { bool flag = true; for (int i = 1; i < 101; ++i) { if (cnt[i] + tot >= k) { if (k - cnt[i] % k <= tot) { tot -= k - cnt[i] % k; cnt[i] += k - cnt[i] % k; } flag = false; tot += (cnt[i] / k) * (k - 1); cnt[i] %= k; } }
if (flag) break; }
for (int i: cnt) tot += i; cout << tot << endl; } }
voidsolve(){ int _; cin >> _; for (int tc = 0; tc < _; ++tc) { int n, m; cin >> n >> m; vector<string> mp(n); for (auto &i: mp) { i.resize(m); cin >> i; } if (mp[0][0] == mp[n - 1][m - 1] || mp[n - 1][0] == mp[0][m - 1]) { cout << "YES" << endl; continue; } bool flag = false; if (mp[0][0] == mp[n - 1][0]) for (int i = 0; i < n; ++i) if (mp[0][0] == mp[i][m - 1]) flag = true; if (mp[0][m - 1] == mp[n - 1][m - 1]) for (int i = 0; i < n; ++i) if (mp[0][m - 1] == mp[i][0]) flag = true;
if (mp[0][0] == mp[0][m - 1]) for (int i = 0; i < m; ++i) if (mp[0][0] == mp[n - 1][i]) flag = true; if (mp[n - 1][0] == mp[n - 1][m - 1]) for (int i = 0; i < m; ++i) if (mp[n - 1][0] == mp[0][i]) flag = true;