Codeforces849c from y to y

阅读全文大概需要 3分钟
本文总阅读量
Posted by yjjr's blog on February 6, 2018

标签:模拟

From beginning till end, this message hasbeen waiting to be conveyed.

For a given unordered multiset ofnlowercase English letters ("multi" means that a letter may appearmore than once), we treat all letters as strings of length 1, and repeat thefollowing operationn - 1 times:

  • Remove any two elementss and t from the set, and add their concatenation s + t to the set.

The cost of such operation is defined to be, wheref(s, c) denotes the number of times characterc appears in strings.

Given a non-negative integerk,construct any valid non-empty set of no more than 100 000 letters, such that the minimum accumulative cost of the wholeprocess is exactlyk. It can be shown that a solution always exists.

Input

The first and only line of input contains anon-negative integerk (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 therequirements, concatenated to be a string.

Note that the printed string doesn't needto be the final concatenated string. It only needs to represent an unorderedmultiset of letters.

Example

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 provedto be the minimum cost of the process.

 

 

题意:给你一个字符串序列的最小价值,求该字符串本身,反正题意十分不明确

最小价值:定义每个小写字母在字符串中出现x次,那么cost=sum(x*(x+1)/2)

题目中那些玄学的价值计算方法都是浮云,实际上就是反着倒退模拟,

参考代码

#include<bits/stdc++.h>
using namespace std;

int n,k;
int main()
{
	cin>>n;
	for(int i=1;i<=26;i++)
	{
		k=1;
		while(k*(k+1)/2<=n)k++;
		n-=k*(k-1)/2;
		for(int j=1;j<=k;j++)printf("%c",'a'+i-1);
	}
	return 0;
}



本文可以转载,但必须附上原文链接,否则你会终生找不到妹子!!!欢迎关注我的CSDN: ahyjjr