Under construction

Still being built. Things may change

Enumeration of Tournaments

Time limit1sMemory limit256 MB

Summary
Given n players in a single-elimination bracket with random pairings each round, count the distinct possible tournaments modulo 2^64 for n up to 10^18.
Level

Hard8 of 10

Topics
Combinatorics, Recursion, Math
Solved
No attempts yet

Problem

Suppose that nn players participate in a single-elimination tournament. The tournament goes round by round. Let kk be the number of remaining players at the beginning of a round. The players then form ⌊k2⌋\lfloor \frac{k}{2} \rfloor random pairs, and every possible partition into pairs is equally likely. In each pair, the two players play one game, the one with the higher rating wins, and the loser leaves the tournament. The remaining ⌊k+12⌋\lfloor \frac{k + 1}{2} \rfloor players advance to the next round.

Each participant has a unique rating, and the result of each game is fully determined by the ratings: the player with the higher rating always wins. The only thing that affects the schedule of the tournament is the random pairing made in each round. Count the number of different tournaments that could occur. Two tournaments are different if some game between two participants occurs in one of them but not in the other.

The answer can be large, so output it modulo 2642^{64}.

Input

The input contains one integer nn, the initial number of players (1≤n≤10181 \le n \le 10^{18}).

Output

Output the number of different tournaments modulo 2642^{64}.

Examples2

  1. Example 1

    Input
    4
    
    Expected output
    3
    
  2. Example 2

    Input
    5
    
    Expected output
    45