結果
問題 | No.16 累乗の加算 |
ユーザー | mastersatoshi |
提出日時 | 2015-08-15 12:15:29 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 139 ms / 5,000 ms |
コード長 | 1,103 bytes |
コンパイル時間 | 3,409 ms |
コンパイル使用メモリ | 75,580 KB |
実行使用メモリ | 56,196 KB |
最終ジャッジ日時 | 2023-09-08 11:45:26 |
合計ジャッジ時間 | 6,079 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 126 ms
55,588 KB |
testcase_01 | AC | 123 ms
55,604 KB |
testcase_02 | AC | 135 ms
55,736 KB |
testcase_03 | AC | 127 ms
56,196 KB |
testcase_04 | AC | 132 ms
55,808 KB |
testcase_05 | AC | 133 ms
55,736 KB |
testcase_06 | AC | 133 ms
55,848 KB |
testcase_07 | AC | 134 ms
55,380 KB |
testcase_08 | AC | 132 ms
55,656 KB |
testcase_09 | AC | 139 ms
55,780 KB |
testcase_10 | AC | 134 ms
56,192 KB |
testcase_11 | AC | 123 ms
55,852 KB |
testcase_12 | AC | 135 ms
55,792 KB |
testcase_13 | AC | 134 ms
53,496 KB |
ソースコード
import java.io.*; import java.util.*; public class Main { static ArrayList<Long> xs = new ArrayList(); static ArrayList<Long> xn = new ArrayList(); public static void main(String[] args) throws Exception { Scanner sc = new Scanner(System.in); long x = sc.nextLong(); pre(x); int n = sc.nextInt(); long a = 0; for (int i = 0; i < n; i++) { a += empowerment(sc.nextLong()); } System.out.println(surplus(a)); } private static long surplus(long source) { return source % 1000003; } private static long empowerment(long a) { long tmpX = 1; for (int i = xn.size() - 1; i >= 0; i--) { long tmp = xn.get(i); if (a >= tmp) { tmpX = surplus(tmpX * xs.get(i)); a = a - tmp; } } return tmpX; } private static void pre(long x) { for (long i = 1; i < 1000000000; i = i + i) { xs.add(x); xn.add(i); x = surplus(x * x); } } }