atcoder#ARC135A. [ARC135A] Floor, Ceil - Decomposition

[ARC135A] Floor, Ceil - Decomposition

Score : 300300 points

Problem Statement

There is an integer XX written on a blackboard. You can do the operation below any number of times (possibly zero).

  • Choose an integer xx written on the blackboard.
  • Erase one xx from the blackboard and write two new integers x2\lfloor \frac{x}{2}\rfloor and x2\lceil \frac{x}{2}\rceil.

Find the maximum possible product of the integers on the blackboard after your operations, modulo 998244353998244353.

What are $\lfloor \frac{x}{2}\rfloor$ and $\lceil \frac{x}{2}\rceil$?

For a real number xx, x\lfloor x\rfloor denotes the largest integer not greater than xx, and x\lceil x\rceil denotes the smallest integer not less than xx. For example, the following holds.

  • For x=2x = 2, we have x2=1\lfloor \frac{x}{2}\rfloor = 1 and x2=1\lceil \frac{x}{2}\rceil = 1.
  • For x=3x = 3, we have x2=1\lfloor \frac{x}{2}\rfloor = 1, x2=2\lceil \frac{x}{2}\rceil = 2.

Constraints

  • 1X10181\leq X \leq 10^{18}

Input

Input is given from Standard Input from the following format:

XX

Output

Print the maximum possible product of the integers on the blackboard after your operations, modulo 998244353998244353.

15
192

Here is a sequence of operations that makes the product of the integers on the blackboard 192192.

  • The initial state of the blackboard is (15)(15).
  • An operation with x=15x = 15 changes it to (7,8)(7, 8).
  • An operation with x=7x = 7 changes it to (8,3,4)(8, 3, 4).
  • An operation with x=4x = 4 changes it to (8,3,2,2)(8, 3, 2, 2).
  • An operation with x=8x = 8 changes it to (3,2,2,4,4)(3, 2, 2, 4, 4).

Here, the product of the integers on the blackboard is 3×2×2×4×4=1923\times 2\times 2\times 4\times 4 = 192.

3
3

Doing zero operations makes the product of the integers on the blackboard 33.

100
824552442

The maximum possible product of the integers on the blackboard after your operations is 58564588684700165856458868470016, which should be printed modulo 998244353998244353.