CF848A.From Y to Y
普及/提高-
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
From beginning till end, this message has been waiting to be conveyed.
For a given unordered multiset of n lowercase English letters ("multi" means that a letter may appear more than once), we treat all letters as strings of length 1, and repeat the following operation n - 1 times:
- Remove any two elements s and t from the set, and add their concatenation s + t to the set.
The cost of such operation is defined to be
, where f(s, c) denotes the number of times character c appears in string s.
Given a non-negative integer k, construct any valid non-empty set of no more than 100 000 letters, such that the minimum accumulative cost of the whole process is exactly k. It can be shown that a solution always exists.
从开始到结束,这条消息一直在等待被传达。
给定一个由 $ n $ 个小写英文字母组成的无序多重集(“多重”表示某个字母可能出现多次),我们将所有字母视作长度为 1 的字符串,并重复执行以下操作 $ n-1 $ 次:
- 从集合中任选两个元素 $ s $ 和 $ t $ 并将其移除,然后将它们的连接串 $ s + t $ 加入集合。
该操作的代价定义为
,其中 $ f(s,,c) $ 表示字符 $ c $ 在字符串 $ s $ 中出现的次数。
给定一个非负整数 $ k $,请构造任意一个合法的、非空且包含至多 $ 100,000 $ 个字母的集合,使得整个过程的最小累计代价恰好为 $ k $。可以证明,这样的解总是存在的。
输入格式
The first and only line of input contains a non-negative integer k (0 ≤ k ≤ 100 000) — the required minimum cost.
输入仅有一行,包含一个非负整数 k(0 ≤ k ≤ 100000)——即所要求的最小代价。
输出格式
Output a non-empty string of no more than 100 000 lowercase English letters — any multiset satisfying the requirements, concatenated to be a string.
Note that the printed string doesn't need to be the final concatenated string. It only needs to represent an unordered multiset of letters.
输出一个非空字符串,长度不超过 100 000,且仅由小写英文字母组成——即任意一个满足要求的多重集,将其元素连接而成的字符串。
注意:所输出的字符串无需是最终拼接得到的字符串;它只需表示一个字母的无序多重集。
输入输出样例
输入#1
12
输出#1
abababab
输入#2
3
输出#2
codeforces
说明/提示
For the multiset {'a', 'b', 'a', 'b', 'a', 'b', 'a', 'b'}, one of the ways to complete the process is as follows:
- {"ab", "a", "b", "a", "b", "a", "b"}, with a cost of 0;
- {"aba", "b", "a", "b", "a", "b"}, with a cost of 1;
- {"abab", "a", "b", "a", "b"}, with a cost of 1;
- {"abab", "ab", "a", "b"}, with a cost of 0;
- {"abab", "aba", "b"}, with a cost of 1;
- {"abab", "abab"}, with a cost of 1;
- {"abababab"}, with a cost of 8.
The total cost is 12, and it can be proved to be the minimum cost of the process.
对于多重集 {′a′,′b′,′a′,′b′,′a′,′b′,′a′,′b′},完成该过程的一种方式如下:
- {"ab","a","b","a","b","a","b"},代价为 0;
- {"aba","b","a","b","a","b"},代价为 1;
- {"abab","a","b","a","b"},代价为 1;
- {"abab","ab","a","b"},代价为 0;
- {"abab","aba","b"},代价为 1;
- {"abab","abab"},代价为 1;
- {"abababab"},代价为 8。
总代价为 12,且可以证明这是该过程的最小代价。
输入解题思路,AI测评打分。不知道怎么写?