#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 00, a cell is created. Every aa hours, the number of cells becomes twice the current amount. Every bb hours, the number of cells becomes half of the current amount (rounded up).

If the current time is a common multiple of aa and bb, then the number of cells does not change. After kk hours, how many cells are there? Output the answer modulo 998244353998244353.

Input Format

One line with 33 positive integers, representing a,b,ka, b, k.

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 11 to 66 are 1,1,2,1,1,21, 1, 2, 1, 1, 2, respectively.

Constraints

For all data, 1a,b,k1061 \le a, b, k \le 10^6.

This problem uses bundled testdata.

Subtask ID Score kk \le Special Property
11 1515 10610^6 Guaranteed a=ba = b
22 2020 Guaranteed a>ba \gt b
33 2525 2020 None
44 4040 10610^6

Hint

$\dfrac{a}{2} \equiv a \times 499122177 \pmod {998244353}$, that is, when taking modulo 998244353998244353, you can use a×499122177a \times 499122177 instead of a÷2a \div 2.

Translated by ChatGPT 5