結果
問題 | No.403 2^2^2 |
ユーザー | tenten |
提出日時 | 2021-01-25 15:57:54 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 154 ms / 2,000 ms |
コード長 | 1,236 bytes |
コンパイル時間 | 3,398 ms |
コンパイル使用メモリ | 81,428 KB |
実行使用メモリ | 57,200 KB |
最終ジャッジ日時 | 2023-09-04 07:47:32 |
合計ジャッジ時間 | 9,696 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 150 ms
56,760 KB |
testcase_01 | AC | 151 ms
56,832 KB |
testcase_02 | AC | 148 ms
57,140 KB |
testcase_03 | AC | 149 ms
57,200 KB |
testcase_04 | AC | 147 ms
56,700 KB |
testcase_05 | AC | 149 ms
56,676 KB |
testcase_06 | AC | 150 ms
56,840 KB |
testcase_07 | AC | 151 ms
56,792 KB |
testcase_08 | AC | 150 ms
56,908 KB |
testcase_09 | AC | 150 ms
55,136 KB |
testcase_10 | AC | 151 ms
56,712 KB |
testcase_11 | AC | 153 ms
56,828 KB |
testcase_12 | AC | 151 ms
56,852 KB |
testcase_13 | AC | 154 ms
57,012 KB |
testcase_14 | AC | 151 ms
56,924 KB |
testcase_15 | AC | 151 ms
56,544 KB |
testcase_16 | AC | 149 ms
56,800 KB |
testcase_17 | AC | 151 ms
56,948 KB |
testcase_18 | AC | 150 ms
57,016 KB |
testcase_19 | AC | 151 ms
56,708 KB |
testcase_20 | AC | 151 ms
56,956 KB |
testcase_21 | AC | 149 ms
56,936 KB |
testcase_22 | AC | 150 ms
56,952 KB |
testcase_23 | AC | 150 ms
57,076 KB |
testcase_24 | AC | 150 ms
57,196 KB |
testcase_25 | AC | 148 ms
56,548 KB |
testcase_26 | AC | 150 ms
56,964 KB |
testcase_27 | AC | 148 ms
56,848 KB |
testcase_28 | AC | 150 ms
56,508 KB |
testcase_29 | AC | 154 ms
56,800 KB |
ソースコード
import java.util.*; public class Main { static final int MOD = 1000000007; static final int MODN = MOD - 1; public static void main(String[] args) { Scanner sc = new Scanner(System.in); String line = sc.nextLine(); int idx = line.indexOf('^'); long a = Long.parseLong(line.substring(0, idx)) % MOD; int next = line.indexOf('^', idx + 1); long b = Long.parseLong(line.substring(idx + 1, next)); long c = Long.parseLong(line.substring(next + 1, line.length())); long x = pow(pow(a, b), c); long m = powmod(b % MODN, c); if (m == 0) { m = MODN; } long y = pow(a, m); System.out.println(x + " " + y); } static long pow(long x, long p) { if (p == 0) { return 1; } else if (p % 2 == 0) { return pow(x * x % MOD, p / 2); } else { return pow(x, p - 1) * x % MOD; } } static long powmod(long x, long p) { if (p == 0) { return 1; } else if (p % 2 == 0) { return powmod(x * x % MODN, p / 2); } else { return powmod(x, p - 1) * x % MODN; } } }