#P10583. [蓝桥杯 2024 国 A] 异或路径

    ID: 12068 远端评测题 1000ms 512MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>2024分块字典树 Trie快速沃尔什变换 FWT蓝桥杯国赛根号分治

[蓝桥杯 2024 国 A] 异或路径

Problem Description

Given a tree with nn nodes, numbered from 11 to nn. For each node with index x>1x > 1, there is an edge to the node with index x\lfloor \sqrt x \rfloor, and the edge weight is xx2x-\lfloor \sqrt x \rfloor ^ 2.

Define the value of a path as the XOR sum of the weights of all edges on this path. If two paths contain different edges, they are considered different paths. Find the product of the values of all essentially different simple paths in this tree (excluding those with value 00), and output the answer modulo 998 244 353998\ 244\ 353.

Input Format

The input contains one line with one integer nn.

Output Format

Output one line with one integer representing the answer.

5
36

Hint

For 40%40\% of the testdata, n103n\le 10^3.
For 70%70\% of the testdata, n106n\le 10^6.
For all testdata, 1n1091\le n\le 10^9.

Translated by ChatGPT 5