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 cappears 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.

Input

The first and only line of input contains a non-negative integer k (0 ≤ k ≤ 100 000) — the required minimum cost.

Output

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.

Examples
input
12
output
abababab
input
3
output
codeforces
Note

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没有重复的,0*0

aba和b有一个重复的 1*1

然后。。为什么最后等于8了我也没想(为什么不是4*4或者1*1?)

反正最后我们加起来等于n就行

解法:

1 构造当然想最容易的 n=12

a a a a这种合并就很简单,0+1+2+3就行

2 我们拿5个a,花费了10,还差2

3 换个字母b,拿两个b b ,还差1

4 再换个字母c,两个c c 搞定

 #include<bits/stdc++.h>
using namespace std;
double x[];
set<double>Se;
double ans;
int main(){
int n;
cin>>n;
string s="";
if(n==){
cout<<"a"<<endl;
}else{
char c='a';
while(n){
int sum=;
int i=;
for(i=;sum<=n;i++){
sum+=i;
} n-=(sum-i+);
for(int j=;j<i-;j++){
s+=c;
}
c++;
}
cout<<s<<endl;
}
return ;
}

最新文章

  1. [PHP][位转换积累]之异或运算的简单加密应用
  2. 仿QQ消息气泡提醒
  3. python第十二天-----RabbitMQ
  4. Quicksum-S.B.S.
  5. linux配置mysql,tomcat命令vi
  6. android开发教程(八)——环境搭建之java-ndk
  7. 【转】在VMware中安装OS X Yosemite
  8. python 10min系列之实现增删改查系统
  9. linux i2c驱动架构-dm368 i2c驱动分析
  10. 《Shell脚本学习指南》学习笔记之变量、判断和流程控制
  11. nginx加权轮询和ip_hash
  12. docker容器日志收集方案(方案N,其他中间件传输方案)
  13. JAVA进阶3
  14. mysql查看变量/配置文件位置
  15. bzoj4336 骑士的旅行 (树链剖分+multiset)
  16. Windows中的键盘快捷方式大全
  17. ASP.NET MVC遍历ModelState的错误信息
  18. ELK 的插件安装(head)
  19. 【Loadrunner】【浙江移动项目手写代码】代码备份
  20. hdu2059 dpdpdp玄学5555~~

热门文章

  1. html5--2.5新的布局元素(4)-aside/nav
  2. 【boost】ptree 读写中文的问题
  3. request.getSession()方法的应用
  4. webAPP meta 标签大全
  5. 构造函数参数new class[0]的作用
  6. 如何增加新的PointT类型
  7. Linux安装JDK1.7&amp;nbsp;prm
  8. Javascript中的&quot;\r\n&quot;
  9. JAVA企业级开发-xml基础语法&amp;约束&amp;解析(04)
  10. 将Angular6自己定义的模块发布成npm包