RiseOJ는 solved.ac와 제휴 관계가 없습니다. 티어 아이콘 © solved.ac. solved.ac
포럼
문제 COCI00725

Džeparac

설명

Mother Antonija has earned \(N\) 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 \(k\) (\(0 \le k \le N\)) to keep for herself. The
remaining amount of \(N - k\) euros is then distributed to the sons over \(d\) days.
Mother Antonija may also choose not to distribute anything to her sons, which
corresponds to the case when \(N = k\) and \(d = 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 \(x\) euros on a given day, the other son also receives \(x\) euros, where \(x\) 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 \(k\) is different
• the number of days \(d\) 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 \(10^{9} + 7\).

제약
입력 형식

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

출력 형식

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

서브태스크
서브태스크점수설명

1

12점

\(n \le 10\)

2

17점

\(n \le 1000\)

3

36점

\(n \le 10^{6}\)

4

5점

No additional constraints.

예제 1
입력
4
출력
4
예제 2
입력
5
출력
4
예제 3
입력
793
출력
137435472
설명

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

k = 4 →the mother keeps all the money, so the only distribution is the one where the sons receive no
money.
k = 2 →2 euros remain to be distributed to the sons. The only valid distribution is d = 1, where each
son receives 1 euro.
k = 0 →4 euros remain to be distributed to the sons. There are two valid distributions:
d = 1 →each son receives 2 euros
d = 2 →each day, each son receives 1 euro
k = 1 and k = 3 →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 = 4 different ways of distribution.

문제 정보

생성자가 기록되지 않았습니다.

출처 COCI 2025/2026 Contest 6

평가 및 의견

Džeparac

개요
출제자 난이도 Unrated 레이팅 미적용 의견 0 / 50 공개 집계 (커뮤니티 난이도, 주요 주제, 품질)는 의견이 충분히 모이면 공개됩니다.

Log in to rate problems.

개별 의견

아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.

풀이 제출

Džeparac

게스트로 둘러보고 있습니다. 로그인하면 풀이를 제출하고 진행 상황을 확인할 수 있습니다. 로그인하고 제출하기
공개
C++20 Tab 들여쓰기 · Ctrl+/ 주석 토글 · Enter 자동 들여쓰기
1 1 1 0 공백: 4 · UTF-8