#P9708. [KMOI R1] 集合 First

[KMOI R1] 集合 First

Problem Description

There is a set A={1,2,3,n}A=\{1,2,3\dots,n\}.

Define the alternating sum G(B)G(B) as follows:

  • Sort the elements in set BB from large to small, obtaining B={b1,b2,bcnt}B=\{b_1,b_2\dots,b_{cnt}\} (cntcnt is the number of elements in the set). Then $G(B)=\sum\limits_{i=1}^{cnt}\Big((-1)^{i+1}\times b_i\Big)$.

For example, G({1,2,4,6,9})=96+42+1=6G(\{1,2,4,6,9\})=9-6+4-2+1=6.

In particular, G()=0G(\empty)=0.

Now, given the set A={1,2,3,,n}A=\{1,2,3,\dots,n\}, Xiaoxie wants to know: for any subset PP of AA, compute the total sum of G(P)G(P).

Because Xiaoxie is too weak, please help. Take the answer modulo 911451407911451407.

Input Format

A positive integer nn, representing the given set A={1,2,3,,n}A=\{1,2,3,\dots,n\}.

Output Format

A positive integer ansans, representing the total sum of G(P)G(P) over any subset PP of AA.

The answer is taken modulo 911451407911451407.

2
4
1000
476463243
1919810
193840227

Hint

Explanation for Sample 11

G()=0G(\empty)=0.

G({1})=1G(\{1\})=1.

G({1,2})=1G(\{1,2\})=1.

G({2})=2G(\{2\})=2.

Therefore, ans=G()+G({1})+G({1,2})+G({2})=4ans=G(\empty)+G(\{1\})+G(\{1,2\})+G(\{2\})=4.

Constraints

This problem uses bundled subtask testdata.

Subtask ID Test Points nn\le Score
11 1,21,2 2020 1515
22 353\sim5 10310^3 1010
33 6106\sim10 10910^{9} 3030
44 111711\sim17 101610^{16} 4545

For 100%100\% of the testdata: 1n10161\le n\le 10^{16}.

Postscript

$$\color{orange}{Xiaoxie: Don't hit me, I will never study sets with size greater than\ 30\ again next time.}$$You:I\color{purple}{You: I*****}

Translated by ChatGPT 5