CF142A Help Farmer

题目描述

原本有A×B×C块干草,被偷走若干块后,剩下N块,刚好等于(A−1)×(B−2)×(C−2)。现在已知N的值,不知道ABC的值,求被偷走的干草的最小值和最大值。

输入格式

第一行,一个整数n。

输出格式

第一行,两个整数,分别表示最小值和最大值。 感谢@xukuan 提供的翻译

说明/提示

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.