#P15210. [NWERC 2025] Dreamcatcher
[NWERC 2025] Dreamcatcher
Description
Lately, you are plagued by horrifying nightmares. In those dreams, a swarm of angry Fenwick bees chases you around a tree with heavy and light branches. You hate getting stung by their fiddling bits. Therefore, you decided to build a dreamcatcher three days ago, but the process is tricky, and you can't figure out the details.
Planning your dreamcatcher became so stressful that you spent the last three nights awake, thinking about long strings of yarn, Carmichael numbers, and geometry. The only progress so far is some incomprehensible drawings (see Figure D.) and the observation that the length of a chord that spans degrees of a circle with radius is . But how is this going to help? You would rather have the dreams about Fenwick bees again than being tormented by this dreadful project for one more day. You need to solve this now!

Figure D.: A dreamcatcher with notches, showing two ways of wrapping it in a string of yarn. The dreamcatcher on the left spans notches per chord, while the dreamcatcher on the right spans notches per chord.
To build a dreamcatcher, you take a wheel with evenly spaced notches, numbered from to . You wrap a string of yarn around this wheel, spanning notches per chord: starting at notch , you repeatedly connect the yarn notches ahead until you reach notch again. For example, with and , you would go from notch to , then , , , , , , .
A dreamcatcher's effectiveness depends on the amount of used yarn. You need to choose , the number of notches to span per chord, such that the total length of yarn is maximized. The answer does not depend on the radius of the dreamcatcher.
Input Format
The input consists of:
- One line with an integer (), the number of notches on the wheel.
Output Format
Output an integer () that maximizes the length of used yarn when spanning notches per chord. If there are multiple valid solutions, you may output any one of them.
8
3
5
2
6
5
京公网安备 11011102002149号