A10408 | Bear and Tower of Cubes
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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_{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 $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.
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_{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 $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.
输入格式
The only line of the input contains one integer $m$ ( $1<=m<=10^{15}$ ), meaning that Limak wants you to choose $X$ between $1$ and $m$ , inclusive.
输出格式
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.
输入输出样例
输入 #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 $3^{3}+2^{3}+7·1^{3}=27+8+7=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 $3^{3}+2^{3}+7·1^{3}=27+8+7=42$ .
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted