A1918 | 最大划分乘积
时间限制1s
内存限制128MB
通过 / 提交0/0
题目描述
欧拉工程183题 有改动
Let N be a positive integer and let N be split into k equal parts, r = N/k, so that N = r + r + ... + r.
Let P be the product of these parts, P = r ×r × ... × r = rk.
将正整数N分为k个相等的部分r,有r=N/k
另P=r×r×...×r=rk
For example, if 11 is split into five equal parts, 11 = 2.2 + 2.2 + 2.2 + 2.2 + 2.2, then P = 2.2^5 = 51.53632.
例如,将11分为五等份 则P=2.2^5
Let M(N) = Pmax for a given value of N.
另M(N)为满足要求的对应N的最大的P
It turns out that the maximum for N = 11 is found by splitting eleven into four equal parts which leads to Pmax = (11/4)^4; that is, M(11) = 14641/256 = 57.19140625, which is a terminating decimal.
容易知道,N=11时,Pmax=57.19140625,是有穷小数
However, for N = 8 the maximum is achieved by splitting it into three equal parts, so M(8) = 512/27, which is a non-terminating decimal.
而N=8时,Pmax=512/27,是无尽小数
Let D(N) = N if M(N) is a non-terminating decimal and D(N) = -N if M(N) is a terminating decimal.
设D(n)=n(若M(n)无尽),D(n)=-n(若M(n)有尽)
Let N be a positive integer and let N be split into k equal parts, r = N/k, so that N = r + r + ... + r.
Let P be the product of these parts, P = r ×r × ... × r = rk.
将正整数N分为k个相等的部分r,有r=N/k
另P=r×r×...×r=rk
For example, if 11 is split into five equal parts, 11 = 2.2 + 2.2 + 2.2 + 2.2 + 2.2, then P = 2.2^5 = 51.53632.
例如,将11分为五等份 则P=2.2^5
Let M(N) = Pmax for a given value of N.
另M(N)为满足要求的对应N的最大的P
It turns out that the maximum for N = 11 is found by splitting eleven into four equal parts which leads to Pmax = (11/4)^4; that is, M(11) = 14641/256 = 57.19140625, which is a terminating decimal.
容易知道,N=11时,Pmax=57.19140625,是有穷小数
However, for N = 8 the maximum is achieved by splitting it into three equal parts, so M(8) = 512/27, which is a non-terminating decimal.
而N=8时,Pmax=512/27,是无尽小数
Let D(N) = N if M(N) is a non-terminating decimal and D(N) = -N if M(N) is a terminating decimal.
设D(n)=n(若M(n)无尽),D(n)=-n(若M(n)有尽)
输入格式
输入文件仅一行 为正整数a(5≤a≤32767).
输出格式
输出文件仅一行 为D(5)+D(6)+...+D(a)的值.
输入输出样例
输入 #1
10
输出 #1
-15
输入 #2
100
输出 #2
2438
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?