首页 > 其他分享 >Codeforces 44E Anfisa the Monkey

Codeforces 44E Anfisa the Monkey

时间:2023-01-26 22:14:15浏览次数:69  
标签:Anfisa Monkey int 填上 Codeforces tie 44E cout

https://codeforces.com/contest/44/problem/E


高级又好像很低级的诈骗


首先不难得到 \(a\times k>|s|\texttt{ or }b\times k<|s|\) 无解。

对于每一组考虑先填上 \(a\) 个字符,对于多出来的依次枚举把能填上(设当前剩 \(p\) 个,则能填上的个数为 \(\min(b-a,p)\))的填上即可。


# include <bits/stdc++.h>
using namespace std;
int main () {
	ios :: sync_with_stdio (false);
	cin .tie (0);
	cout .tie (0);
	int k, a, b;
	string s;
	cin >> k >> a >> b >> s;
	int n = s .size ();
	if (n < k * a || n > k * b) {
		cout << "No solution";
		return 0;
	}
	int p = n - k * a, u = 0;
	for (int i = 1; i <= k; ++ i) {
		for (int j = 1; j <= a; ++ j, ++ u) {
			cout << s [u];
		}
		for (int j = 1; j <= min (p, b - a); ++ j, ++ u) {
			cout << s [u];
		}
		p -= min (p, b - a);
		cout << '\n';
	}
	return 0;
}

标签:Anfisa,Monkey,int,填上,Codeforces,tie,44E,cout
From: https://www.cnblogs.com/lctj-bot/p/17068300.html

相关文章