結果

問題 No.16 累乗の加算
ユーザー kano_townkano_town
提出日時 2014-11-19 16:37:08
言語 Java21
(openjdk 21)
結果
TLE  
実行時間 -
コード長 469 bytes
コンパイル時間 3,706 ms
コンパイル使用メモリ 72,676 KB
実行使用メモリ 60,972 KB
最終ジャッジ日時 2023-08-30 21:53:19
合計ジャッジ時間 10,328 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 119 ms
55,740 KB
testcase_01 AC 119 ms
56,132 KB
testcase_02 TLE -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Yukicoder16 {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int N = sc.nextInt();
		long res = 0;
		for (int i = 0; i < N; i++) {
			res += powMod(x, sc.nextInt()) % 1000003;
		}
		System.out.println(res);
	}
	
	static long powMod(int a, int n) {
		long res = 1;
		for (int i = 0; i < n; i++) {
			res = a * (res % 1000003);
		}
		return res;
	}
}
0