CF679B.Bear and Tower of Cubes

提高+/省选-

通过率:0%

时间限制:2.00s

内存限制:256MB

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 a has volume _a_3. A tower consisting of blocks with sides _a_1, _a_2, ..., a__k has the total volume _a_13 + _a_23 + ... + _a__k_3.

Limak is going to build a tower. First, he asks you to tell him a positive integer X — 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 X.

Limak asks you to choose X not greater than m. 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 X.

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

Limak 是一只小北极熊。他通过堆叠积木来玩耍。每块积木都是一个边长为正整数的立方体。Limak 拥有无限多个每种边长的积木。

边长为 aa 的积木体积为 a3a^3。由边长分别为 a1,a2,…,aka_1, a_2, \dots, a_k 的积木组成的塔,其总体积为 a13+a23+⋯+ak3a_1^3 + a_2^3 + \dots + a_k^3。

Limak 将要建造一座塔。首先,他请你告诉他一个正整数 XX —— 即该塔所需的总体积。然后,Limak 以贪心方式逐个添加新积木:每次添加满足“添加后总体积不超过 XX”这一条件的最大可能的积木。

Limak 要求你选择的 XX 不超过 mm。此外,他希望最终塔中积木的数量尽可能多(但他仍严格按上述贪心策略添加)。在积木数量最多的前提下,他其次希望 XX 尽可能大。

你能帮助 Limak 吗?请找出他的塔所能达到的最大积木数量,以及在不超过 mm 的条件下、能达成该最大积木数量的最大 XX 值。

输入格式

The only line of the input contains one integer m (1 ≤ m ≤ 1015), meaning that Limak wants you to choose X between 1 and m, inclusive.

输入仅包含一行,其中有一个整数 mm(1 ≤ m ≤ 10151 \le m \le 10^{15}),表示 Limak 希望你选择一个满足 1≤X≤m1 \le X \le m 的整数 XX。

输出格式

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

输出两个整数——塔中最多可放置的方块数量,以及达到该最多方块数量所需的最大总体积 XX。

输入输出样例

  • 输入#1

    48

    输出#1

    9 42
  • 输入#2

    6

    输出#2

    6 6

说明/提示

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

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

  • Limak takes a block with side 3 because it's the biggest block with volume not greater than 42. The remaining volume is 42 - 27 = 15.
  • The second added block has side 2, so the remaining volume is 15 - 8 = 7.
  • Finally, Limak adds 7 blocks with side 1, one by one.

So, there are 9 blocks in the tower. The total volume is is 33 + 23 + 7·13 = 27 + 8 + 7 = 42.

在第一个样例测试中,若选择 X=23X = 23 或 X=42X = 42,则塔将由 9 个方块组成。Limak 希望在满足块数最多的前提下,其次最大化 XX,因此你应选择 42。

更详细地,当选择 X=42X = 42 时,建塔过程如下:

  • Limak 首先取一个边长为 3 的方块,因为它是体积不超过 42 的最大方块。剩余体积为 42−27=1542 - 27 = 15。
  • 第二个加入的方块边长为 2,因此剩余体积变为 15−8=715 - 8 = 7。
  • 最后,Limak 逐个加入 7 个边长为 1 的方块。

因此,塔中共有 9 个方块。总体积为 33+23+7⋅13=27+8+7=423^3 + 2^3 + 7 \cdot 1^3 = 27 + 8 + 7 = 42。

输入解题思路,AI测评打分。不知道怎么写?

首页