結果

問題 No.16 累乗の加算
ユーザー aaaaasatoriaaaaasatori
提出日時 2018-02-18 15:39:54
言語 Java21
(openjdk 21)
結果
TLE  
実行時間 -
コード長 606 bytes
コンパイル時間 4,683 ms
コンパイル使用メモリ 74,200 KB
実行使用メモリ 63,272 KB
最終ジャッジ日時 2023-09-06 18:30:05
合計ジャッジ時間 11,528 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 120 ms
56,240 KB
testcase_01 AC 119 ms
55,784 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.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class No16 {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long x = sc.nextLong();
		int N = sc.nextInt();
		List<Long> a = new ArrayList<Long>();
		for(int i = 0;i < N;i++) {
			a.add(sc.nextLong());
		}
		Collections.sort(a);
		long xn = 1;
		long sum = 0;
		for(long i = 0;i <= a.get(a.size()-1);i++) {
			if(i != 0) {
				xn = xn * x % 1000003;
			}
			if(a.indexOf(i) != -1) {
				sum = (sum + xn) % 1000003;
			}
		}
		System.out.println(sum);
	}
}
0