CF679B.Bear and Tower of Cubes

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Limak is a little polar bear. He plays by building towers from blocks. Every block is a cube with positive integer length of side. Limak has infinitely many blocks of each side length.

A block with side aa has volume a3a^{3} . A tower consisting of blocks with sides a1,a2,...,aka_{1},a_{2},...,a_{k} has the total volume a13+a23+...+ak3a_{1}^{3}+a_{2}^{3}+...+a_{k}^{3} .

Limak is going to build a tower. First, he asks you to tell him a positive integer XX — the required total volume of the tower. Then, Limak adds new blocks greedily, one by one. Each time he adds the biggest block such that the total volume doesn't exceed XX .

Limak asks you to choose XX not greater than mm . Also, he wants to maximize the number of blocks in the tower at the end (however, he still behaves greedily). Secondarily, he wants to maximize XX .

Can you help Limak? Find the maximum number of blocks his tower can have and the maximum X<=mX<=m that results this number of blocks.

输入格式

The only line of the input contains one integer mm ( 1<=m<=10151<=m<=10^{15} ), meaning that Limak wants you to choose XX between 11 and mm , inclusive.

输出格式

Print two integers — the maximum number of blocks in the tower and the maximum required total volume XX , resulting in the maximum number of blocks.

输入输出样例

  • 输入#1

    48
    

    输出#1

    9 42
    
  • 输入#2

    6
    

    输出#2

    6 6
    

说明/提示

In the first sample test, there will be 99 blocks if you choose X=23X=23 or X=42X=42 . Limak wants to maximize XX secondarily so you should choose 4242 .

In more detail, after choosing X=42X=42 the process of building a tower is:

  • Limak takes a block with side 33 because it's the biggest block with volume not greater than 4242 . The remaining volume is 4227=1542-27=15 .
  • The second added block has side 22 , so the remaining volume is 158=715-8=7 .
  • Finally, Limak adds 77 blocks with side 11 , one by one.

So, there are 99 blocks in the tower. The total volume is is 33+23+713=27+8+7=423^{3}+2^{3}+7·1^{3}=27+8+7=42 .

首页