結果

問題 No.16 累乗の加算
ユーザー rn4rurn4ru
提出日時 2016-04-13 02:46:54
言語 Java21
(openjdk 21)
結果
TLE  
実行時間 -
コード長 520 bytes
コンパイル時間 2,223 ms
コンパイル使用メモリ 73,940 KB
実行使用メモリ 46,680 KB
最終ジャッジ日時 2024-04-15 00:25:38
合計ジャッジ時間 9,051 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 116 ms
41,004 KB
testcase_01 AC 122 ms
41,340 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 Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		final int m = 1000003;
		int x = scanner.nextInt();
		int N = scanner.nextInt();

		int[] a = new int[N];
		for (int i = 0; i < N; i++) {
			a[i] = scanner.nextInt();
		}

		int sum = 0;
		for (int i = 0; i < N; i++) {
			int xa = 1;
			for (int j = 0; j < a[i]; j++) {
				xa *= x;
				while (xa > m) {
					xa -= m;
				}
			}
			sum += xa;
		}
		System.out.println(sum % m);
	}

}
0