#P2675. 《瞿葩的数字游戏》T3-三角圣地

    ID: 1690 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 难度: 7 上传者: 标签>数学贪心洛谷原创组合数学Lucas 定理

《瞿葩的数字游戏》T3-三角圣地

Description

The center of the Kingdom of Numbers is formed by an inverted triangle.

The inverted triangle has NN layers. The ii-th layer from top to bottom contains Ni+1N - i + 1 numbers. The first layer must be one of the permutations of 1N1 \sim N, that is, it must use all numbers from 11 to NN without repetition. Starting from the second layer, each number is obtained by adding the two numbers above it to the left and right. For example, the following is a valid inverted triangle:

1   2   3   4
  3   5   7
    8   12
      20

This inverted triangle has N=4N = 4, and the last-layer number is 2020.

The Kingdom of Numbers calls the last-layer number the 'base'. Please write a program to compute the maximum value of the 'base' modulo 1000710007.

Input Format

One line containing an integer NN, representing the number of layers of the inverted triangle.

Output Format

One line containing an integer, which is the maximum possible 'base' for NN layers modulo 1000710007.

4
24
1125
700

Hint

  • Sample Explanation

One feasible arrangement is:

1   3   4   2
  4   7   6
    11  13
      24

It can be proved that there is no better method.

  • Constraints

For 20%20\% of the testdata, N100N \le 100.

For 50%50\% of the testdata, N3000N \le 3000.

For 100%100\% of the testdata, 0N1060 \le N \le {10}^6.

Translated by ChatGPT 5