#P8588. 『JROI-8』雷雨天特别行动科

『JROI-8』雷雨天特别行动科

Background

1663764044201.png

"Angels do not have vacations."
"Ah, again... It is better not to push yourself too hard."

Reprint authorization has been obtained.

Problem Description

For a non-negative integer variable xx, define one round of operations as follows:

  1. Increase xx by 11.
  2. If xx is a multiple of 33, divide xx by 33.

Given the initial xx and kk, find the value of xx after kk rounds of operations.

Note: The large sample is not provided as an attached file. Instead, it is placed directly in Sample #3 of the Input/Output Samples.

Input Format

One line with two non-negative integers x,kx, k.

Output Format

One line with one positive integer, representing the value of xx after kk rounds of operations.

1 3
2
10 3
5
1919810 3
213313

Hint

[Sample Explanation]

For Sample 1, the change process of xx is as follows: $1\rightarrow 2\rightarrow (3\rightarrow 1)\rightarrow 2$.

The part in parentheses represents one operation.

[Constraints and Notes]

For all testdata, 0x,k10180\leq x, k\leq 10^{18}.

In particular, in test points 121\sim 2, k0k\leq 0 is equivalent to k=0k=0, and similarly for xx in 343\sim 4.

Test Point ID Score xx\leq kk\leq
121\sim 2 2020 55 00
343\sim 4 00 101810^{18}
565\sim 6 101810^{18} 10610^6
7107 \sim 10 4040 101810^{18}

Translated by ChatGPT 5