voidsolve(){ int _; cin >> _; for (int tc = 0; tc < _; ++tc) { int n, m; cin >> n >> m; for (int i = 0; i < n; ++i) for (int j = 0; j < m; ++j) cout << static_cast<char>('a' + j); cout << endl; } }
voidsolve(){ int _; cin >> _; for (int tc = 0; tc < _; ++tc) { int n, m; cin >> n >> m; constint r = static_cast<int>(sqrt(n)) + 1; int ans = 1; for (int i = 1; i <= min(r, n); ++i) { if (n % i != 0) continue; if (i >= m) ans = max(ans, n / i); elseif (n / i >= m) ans = max(ans, i); } cout << ans << endl; } }
voidsolve(){ int _; cin >> _; for (int tc = 0; tc < _; ++tc) { int n, k, m; cin >> n >> k >> m; string str; str.resize(m); cin >> str; set<char> st; int tot = 0; vector<char> ans; for (constauto& c: str) { if (c < 'a' || c >= 'a' + k) continue; st.insert(c); if (st.size() == k) { st.clear(); ++tot; ans.push_back(c); } } if (tot >= n) cout << "YES" << endl; else { cout << "NO" << endl; char c = 'a'; for (char i = 0; i < k; ++i) if (!st.count(i + 'a')) c = i + 'a'; for (int i = 0; i < n; ++i) if (i < ans.size()) cout << ans[i]; else cout << c; cout << endl; } } }
voidsolve(){ int _; cin >> _; for (int tc = 0; tc < _; ++tc) { constexprint mod = 1e9 + 7; auto qp = [&](int a, int p) { int ans = 1; while (p) { if (p & 1) ans = ans * a % mod; a = a * a % mod; p >>= 1; } return ans; }; int n, m, k; cin >> n >> m >> k; constint i = qp(n * (n - 1) / 2 % mod, mod - 2); vector<tuple<int, int, int>> data(m); for (auto& [l, r, v]: data) cin >> l >> r >> v; int ans = 0; for (constauto [_l, _r, v]: data) { constint l = v * k % mod; constint r = i * ((k - 1) * k / 2 % mod) % mod; constint t = (l + r) * i % mod; ans = (ans + t) % mod; } cout << ans << endl; } }