No.1578 A × B × C
Problem Statement
You are given 3 positive integers $A, B, C$ and a positive integer $K$. Initially, the 3 numbers $A, B, C$ are written on a blackboard.
Perform the following operation $K$ times.
-
Simultaneously rewrite each of the 3 numbers written on the blackboard with the product of the other 2 numbers.
Find the product of the 3 numbers written on the blackboard after the operations are finished, modulo $10^9+7$.
Input
$A\ \ B\ \ C$ $K$
- $1 \leq A, B, C \leq 10^9$
- $1 \leq K \leq 10^{12}$
- All inputs are integers.
Output
Output the value you found, followed by a newline.
Sample
Sample 1
Input
2 3 1 1
Output
36
The numbers written on the blackboard become $3,\ 2,\ 6$, and their product $36$ is the answer.
Sample 2
Input
1 1 1 4879314
Output
1
No matter how many times the operation is performed, the numbers remain $1,\ 1,\ 1$.
Sample 3
Input
390421437 291872136 531083427 292874319324
Output
664210506
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
magsta
Kazun