#P9577. 「Cfz Round 1」Dead Cells
「Cfz Round 1」Dead Cells
Background
After finishing a biology class on Cidoai, a sudden idea came up, and they created this problem.
"It is too easy... maybe." Cidoai said, and then gave you this problem, asking you to discover the fun in it.
Problem Description
One day, at hour , a cell is created. Every hours, the number of cells becomes twice the current amount. Every hours, the number of cells becomes half of the current amount (rounded up).
If the current time is a common multiple of and , then the number of cells does not change. After hours, how many cells are there? Output the answer modulo .
Input Format
One line with positive integers, representing .
Output Format
One line with one integer, representing the answer.
3 4 6
2
4 7 16
4
3 2 5
1
114 5141 919810
62166352
Hint
Sample Explanation #1
The numbers of cells from hour to are , respectively.
Constraints
For all data, .
This problem uses bundled testdata.
| Subtask ID | Score | Special Property | |
|---|---|---|---|
| Guaranteed | |||
| Guaranteed | |||
| None | |||
Hint
$\dfrac{a}{2} \equiv a \times 499122177 \pmod {998244353}$, that is, when taking modulo , you can use instead of .
Translated by ChatGPT 5