CF177B1.Rectangular Game
入门
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
The Smart Beaver from ABBYY decided to have a day off. But doing nothing the whole day turned out to be too boring, and he decided to play a game with pebbles. Initially, the Beaver has n pebbles. He arranges them in a equal rows, each row has b pebbles (a > 1). Note that the Beaver must use all the pebbles he has, i. e. n = a·b.
10 pebbles are arranged in two rows, each row has 5 pebbles
Once the Smart Beaver has arranged the pebbles, he takes back any of the resulting rows (that is, b pebbles) and discards all other pebbles. Then he arranges all his pebbles again (possibly choosing other values of a and b) and takes back one row, and so on. The game continues until at some point the Beaver ends up with exactly one pebble.
The game process can be represented as a finite sequence of integers _c_1, ..., c__k, where:
- _c_1 = n
- c__i + 1 is the number of pebbles that the Beaver ends up with after the i-th move, that is, the number of pebbles in a row after some arrangement of c__i pebbles (1 ≤ i < k). Note that c__i > c__i + 1.
- c__k = 1
The result of the game is the sum of numbers c__i. You are given n. Find the maximum possible result of the game.
来自ABBYY的聪明海狸决定休息一天。但一整天无所事事实在太无聊了,于是他决定玩一个石子游戏。初始时,海狸有 n 颗石子。他将这些石子排成 a 行相等的行,每行有 b 颗石子(其中 a>1)。注意:海狸必须用完他所拥有的全部石子,即 n=a⋅b。
10颗石子被排成两行,每行5颗石子
一旦聪明海狸将石子排好,他就取回其中任意一行(即 b 颗石子),并将其余所有石子全部丢弃。接着,他再次将手中所有石子重新排列(可能选择不同的 a 和 b 值),再取回其中一行,如此反复。游戏持续进行,直到某次操作后海狸手中恰好只剩一颗石子为止。
整个游戏过程可表示为一个有限整数序列 c1,…,ck,满足:
- c1=n;
- 对于 1≤i<k,ci+1 表示第 i 次操作后海狸手中剩余的石子数,即在将 ci 颗石子以某种方式排列后,某一行中的石子数量。注意:ci>ci+1;
- ck=1。
游戏的结果定义为序列中所有数之和 ∑i=1kci。现给定 n,求游戏结果的最大可能值。
输入格式
The single line of the input contains a single integer n — the initial number of pebbles the Smart Beaver has.
The input limitations for getting 30 points are:
- 2 ≤ n ≤ 50
The input limitations for getting 100 points are:
- 2 ≤ n ≤ 109
输入仅包含一行,其中有一个整数 n —— 表示聪明的海狸最初拥有的鹅卵石数量。
获得 30 分的输入限制为:
- 2 ≤ n ≤ 50
获得 100 分的输入限制为:
- 2 ≤ n ≤ 109
输出格式
Print a single number — the maximum possible result of the game.
输出一个数字——游戏可能得到的最大结果。
输入输出样例
输入#1
10
输出#1
16
输入#2
8
输出#2
15
说明/提示
Consider the first example (_c_1 = 10). The possible options for the game development are:
- Arrange the pebbles in 10 rows, one pebble per row. Then _c_2 = 1, and the game ends after the first move with the result of 11.
- Arrange the pebbles in 5 rows, two pebbles per row. Then _c_2 = 2, and the game continues. During the second move we have two pebbles which can be arranged in a unique way (remember that you are not allowed to put all the pebbles in the same row!) — 2 rows, one pebble per row. _c_3 = 1, and the game ends with the result of 13.
- Finally, arrange the pebbles in two rows, five pebbles per row. The same logic leads us to _c_2 = 5, _c_3 = 1, and the game ends with the result of 16 — the maximum possible result.
考虑第一个例子(c1=10)。游戏开发的可能方案如下:
- 将石子排成 10 行,每行 1 颗石子。此时 c2=1,游戏在第一步后结束,结果为 11。
- 将石子排成 5 行,每行 2 颗石子。此时 c2=2,游戏继续进行。在第二步中,我们有 2 颗石子,它们只能以唯一方式排列(注意:不允许将所有石子放在同一行!)—— 即排成 2 行,每行 1 颗石子。此时 c3=1,游戏结束,结果为 13。
- 最后,将石子排成 2 行,每行 5 颗石子。依同样逻辑可得 c2=5,c3=1,游戏结束,结果为 16 —— 这是可能的最大结果。
输入解题思路,AI测评打分。不知道怎么写?