A. Uniform String
https://codeforces.com/problemset/problem/1092/A
같은 문자가 최대한 적게 나오게 해야한다.
n개를 출력하는데 n/k + n%k개가 minimum이다.
그래서 k주기로 쭉 출력한다.
만약 k가 4이고, n이 10이면 abcd abcd ab 이런식으로.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | #include <bits/stdc++.h> using namespace std; int t, n, k; int main() { ios::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); cin >> t; while (t--) { cin >> n >> k; for (int i = 0; i < n; i++) { cout << (char)('a' + i % k); } cout << '\n'; } return 0; } | cs |
'Competition > codeforces' 카테고리의 다른 글
Educational Codeforces Round 62 (Rated for Div. 2) A. Detective Book (0) | 2019.04.01 |
---|---|
Codeforces Round #548 (Div. 2) A. Even Substrings (0) | 2019.03.30 |
Codeforces Round #527 (Div. 3) B. Teams Forming (0) | 2019.03.30 |
Codeforces Round #516 (Div. 2, by Moscow Team Olympiad) A. Make a triangle! (0) | 2019.03.30 |
Educational Codeforces Round 52 (Rated for Div. 2) A. Vasya and Chocolate (0) | 2019.03.30 |