A8269 | Help Farmer
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Once upon a time in the Kingdom of Far Far Away lived Sam the Farmer. Sam had a cow named Dawn and he was deeply attached to her. Sam would spend the whole summer stocking hay to feed Dawn in winter. Sam scythed hay and put it into haystack. As Sam was a bright farmer, he tried to make the process of storing hay simpler and more convenient to use. He collected the hay into cubical hay blocks of the same size. Then he stored the blocks in his barn. After a summer spent in hard toil Sam stored $A·B·C$ hay blocks and stored them in a barn as a rectangular parallelepiped $A$ layers high. Each layer had $B$ rows and each row had $C$ blocks.
At the end of the autumn Sam came into the barn to admire one more time the hay he'd been stacking during this hard summer. Unfortunately, Sam was horrified to see that the hay blocks had been carelessly scattered around the barn. The place was a complete mess. As it turned out, thieves had sneaked into the barn. They completely dissembled and took away a layer of blocks from the parallelepiped's front, back, top and sides. As a result, the barn only had a parallelepiped containing $(A-1)×(B-2)×(C-2)$ hay blocks. To hide the evidence of the crime, the thieves had dissembled the parallelepiped into single $1×1×1$ blocks and scattered them around the barn. After the theft Sam counted $n$ hay blocks in the barn but he forgot numbers $A$ , $B$ и $C$ .
Given number $n$ , find the minimally possible and maximally possible number of stolen hay blocks.
At the end of the autumn Sam came into the barn to admire one more time the hay he'd been stacking during this hard summer. Unfortunately, Sam was horrified to see that the hay blocks had been carelessly scattered around the barn. The place was a complete mess. As it turned out, thieves had sneaked into the barn. They completely dissembled and took away a layer of blocks from the parallelepiped's front, back, top and sides. As a result, the barn only had a parallelepiped containing $(A-1)×(B-2)×(C-2)$ hay blocks. To hide the evidence of the crime, the thieves had dissembled the parallelepiped into single $1×1×1$ blocks and scattered them around the barn. After the theft Sam counted $n$ hay blocks in the barn but he forgot numbers $A$ , $B$ и $C$ .
Given number $n$ , find the minimally possible and maximally possible number of stolen hay blocks.
输入格式
The only line contains integer $n$ from the problem's statement ( $1<=n<=10^{9}$ ).
输出格式
Print space-separated minimum and maximum number of hay blocks that could have been stolen by the thieves.
Note that the answer to the problem can be large enough, so you must use the 64-bit integer type for calculations. Please, do not use the %lld specificator to read or write 64-bit integers in С++. It is preferred to use cin, cout streams or the %I64d specificator.
Note that the answer to the problem can be large enough, so you must use the 64-bit integer type for calculations. Please, do not use the %lld specificator to read or write 64-bit integers in С++. It is preferred to use cin, cout streams or the %I64d specificator.
输入输出样例
输入 #1
4
输出 #1
28 41
输入 #2
7
输出 #2
47 65
输入 #3
12
输出 #3
48 105
Let's consider the first sample test. If initially Sam has a parallelepiped consisting of $32=2×4×4$ hay blocks in his barn, then after the theft the barn has $4=(2-1)×(4-2)×(4-2)$ hay blocks left. Thus, the thieves could have stolen $32-4=28$ hay blocks. If Sam initially had a parallelepiped consisting of $45=5×3×3$ hay blocks in his barn, then after the theft the barn has $4=(5-1)×(3-2)×(3-2)$ hay blocks left. Thus, the thieves could have stolen $45-4=41$ hay blocks. No other variants of the blocks' initial arrangement (that leave Sam with exactly 4 blocks after the theft) can permit the thieves to steal less than 28 or more than 41 blocks.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted