eolymp
bolt
Попробуйте наш новый интерфейс для отправки задач
Задачи

Nowhere Money

Nowhere Money

In Nowhere town, people use "coin and slot" as their money. There are \textbf{2} types of coins called size1 and size2. Size2 coin is twice the thickness of size1. People stack their coins in slots and use them as money. There are many size of slots. The slot of size n is able to stack up n size1 coins. Only filled-up slot is considered as legal money. The value of each filled-up slot is the distinct ways its can stack coins inside. For example, for size-1 slot, there is only one way to stack a single size1 coin inside. For size-2 slot, there are \textbf{2} ways to stack two size1 coins or one size2 coin inside. And for size-5 slot, there are 8 ways to stack coins inside, which can be illustrated as follow: \textbf{1 1 1 1 1, 1 1 1 2, 1 1 2 1, 1 2 1 1, 2 1 1 1, 1 2 2, 2 1 2, 2 2 1}. So the value of filled up slot with size-1, size-2 and size-5 are \textbf{1}, 2 and 8 (monetary) units respectively (regardless of the type of coins or the ways they are stacked). Mr.Thinktwice is an owner of a grocery store in this town. He noticed that customers are likely to go to the shop that can return the (money) change in the form that suits their customer. And from his little survey, he found that most customers would like to get their amount of change in the form according to these \textbf{2} simple constraints. \begin{enumerate} \item The number of slots is minimum. \item The size of each slot must be different from each other by at least \end{enumerate} \begin{itemize} \item This means that customers does not want any slots with the same size and it will be easier for them to distinguish these differences if the sizes are not too close. \end{itemize} So Mr.Thinktwice ask you to write a program that can give him a series of slot sizes for a given amount of change according to the previous constraints. Moreover, the series must be sorted in descending order. For more specific, any amount of change can be written in this formula. \includegraphics{https://static.e-olymp.com/content/15/15cfd93f6a8eb1031c2329d4fe422831f495c6c7.jpg} where \begin{itemize} \item \textbf{X} is an amount of change. \item \textbf{n} is the total number of slot. \item \textbf{s_i} is the size of \textbf{i}^th slot. \item \textbf{T} is a function mapping from a slot size to a number of distinct ways of stacking coins. \item and when \textbf{j} ≫ \textbf{k} ≡ \textbf{j} ≥ \textbf{k+2} \end{itemize} For example : \includegraphics{https://static.e-olymp.com/content/d6/d66ce74b91285e88fa77b1d4735b076d8c5d25c0.jpg} \InputFile Input is a standard input which contains a set of integer. Each line of the input is an amount of change which represents by a positive integer less than or equal to \textbf{5000000000000000000} or \textbf{5}×\textbf{10^18}. The input is terminated when the \textbf{EOF} (End-Of-File) is reached. \OutputFile For each amount of change, generate \textbf{4} lines of output data. The first line is the amount of change itself. The second line is a series of slot sizes (in descending order) separated by spaces. (The maximum slot size is less than or equal to \textbf{90}.) The third line is a series of corresponding slot values. The fourth line is a blank line.
Лимит времени 1 секунда
Лимит использования памяти 256 MiB
Входные данные #1
1
10
1000000
Выходные данные #1
1
1
1

10
5 2
8 2

1000000
29 25 23 11 9
832040 121393 46368 144 55