問題一覧 > 通常問題

No.403 2^2^2

レベル : / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 193
作問者 : りあん / テスター : anta
お気に入りにしたユーザー ProblemId : 893 / 自分の提出
問題文最終更新日: 2026-06-28 11:18:52
2^2^2
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Show the original
yukicoder contest 143 (順位表) の他の問題:

Problem Statement

For 2^2^2, the result is the same whether it is computed as (2^2)^2 $((2^2)^2 = 4^2 = 16)$ or as 2^(2^2) $(2^{(2^2)} = 2^4 = 16)$, but in general, exponentiation does not satisfy the associative law.

You are given positive integers $A,B,C$ in the form "A^B^C". Find the values of $(A^B)^C$ and $A^{(B^C)}$, and print them on one line, separated by a space.

Since these can be very large numbers, print the remainders when they are divided by $10^9 + 7$.

Input

A^B^C

Positive integers $A,B,C (1 \leq A,B,C \leq 10^{16})$ are given on one line, separated by ' ^ '.

The input contains no extra whitespace.

Output

Print the values of (A^B)^C and A^(B^C), each modulo $10^9 + 7$, on one line, separated by a space.

Print a newline at the end.

Sample

Sample 1
Input
2^2^2
Output
16 16

This is as shown in the problem statement.

Sample 2
Input
2^3^2
Output
64 512

We have $(2^3)^2 = 8^2 = 64$ $,$ $2^{(3^2)} = 2^9 = 512$.

Sample 3
Input
10^10^10
Output
226732710 206165314

Print the remainders when divided by $10^9 + 7$.

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。