結果

問題 No.16 累乗の加算
ユーザー spaciaspacia
提出日時 2016-01-04 09:58:22
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 720 bytes
コンパイル時間 2,272 ms
コンパイル使用メモリ 74,520 KB
実行使用メモリ 60,668 KB
最終ジャッジ日時 2023-10-19 15:01:07
合計ジャッジ時間 4,412 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

import java.io.*;
import java.util.*;
import java.math.*;

class Main {
	
	public static void out (Object o) {
		System.out.println(o);
	}
	
	public static void main (String[] args) throws IOException {
		BufferedReader br = 
			new BufferedReader(new InputStreamReader(System.in));
		
		String[] line1 = br.readLine().split(" ");
		String[] line2 = br.readLine().split(" ");
		
		int x = Integer.parseInt(line1[0]);
		int n = Integer.parseInt(line1[1]);
		int ans = 0, m = 1000003;
		long[] mm = new long[m];
		
		mm[0] = 1;
		for (int i = 1; i < m; i++) {
			mm[i] = mm[i - 1] * x % m;
		}
		for (int i = 0; i < n; i++) {
			int a = Integer.parseInt(line2[i]);
			ans += mm[a % m];
			ans %= m;
		}
		
		out(ans);
	}
}
0