题目 20403

零花钱

查看题解 ↗GitHub ↗如何评测
题号
20403
时间限制
1000 ms
内存限制
256 MB
标签
比赛CSP-S
来源
CSP-S 国外模拟赛 31 - T1

第 1 题 零花钱 (deparac)

时间限制 1.0 s · 空间限制 256 MB · 104 个测试点 · 全文比较(过滤行末空格及文末回车)

本题使用文件输入输出:输入文件 deparac.in,输出文件 deparac.out。

题目描述

Mother Antonija has earned NN euros and must spend all of it as soon as possible. She may keep a portion of the money for herself, but the remaining amount must be equally distributed to her two sons over several days.

First, she chooses a non-negative integer kk (0≤k≤N0 \le k \le N) to keep for herself. The remaining amount of N−kN - k euros is then distributed to the sons over dd days. Mother Antonija may also choose not to distribute anything to her sons, which corresponds to the case when N=kN = k and d=0d = 0.

If the money is distributed, it is done so that each day both sons receive the same amount of money. If one son receives xx euros on a given day, the other son also receives xx euros, where xx must be a positive integer. In total, each son must receive the same total amount of money.

Two distributions are considered different if at least one of the following holds:

  • the chosen amount kk is different
  • the number of days dd is different
  • there exists at least one day on which the amounts received by the sons differ (i.e., the sequence of daily payments is not identical).

Your task is to determine the number of different ways in which the mother can distribute the money. Since the number of ways can be very large, output the result modulo 109+710^9 + 7.

输入格式

The first line contains a natural number nn (1≤n≤10151 \le n \le 10^{15}), the number from the problem statement.

输出格式

Print a single number - the number of ways in which mother Antonija can distribute the money.

样例

样例 1

输入:

文本
4

输出:

文本
4

样例 2

输入:

文本
5

输出:

文本
4

样例 3

输入:

文本
793

输出:

文本
137435472

提示

Clarification of the first example: We consider all possible values of the number kk:

k=4k = 4 →\to the mother keeps all the money, so the only distribution is the one where the sons receive no money.

k=2k = 2 →\to 2 euros remain to be distributed to the sons. The only valid distribution is d=1d = 1, where each son receives 1 euro.

k=0k = 0 →\to 4 euros remain to be distributed to the sons. There are two valid distributions:

d=1d = 1 →\to each son receives 2 euros

d=2d = 2 →\to each day, each son receives 1 euro

k=1k = 1 and k=3k = 3 →\to there is no way to divide the remaining amount so that both sons receive the same positive integer amount each day.

In total, there are 1+1+2=41 + 1 + 2 = 4 different ways of distribution.

Scoring

Subtask Points Constraints
1 12 n≤10n \le 10
2 17 n≤1000n \le 1000
3 36 n≤106n \le 10^6
4 5 No additional constraints.

数据下载

题目 20403 的公开数据

正在读取文件列表…

常用命令

题目 20403 的 ROJ 命令

以下命令默认使用全局安装的 ROJ Skill,请在终端中直接执行;如果修改过 AGENT_HOME,请将命令中的 ~/.agents 替换为对应目录。