結果

問題 No.16 累乗の加算
ユーザー shinwisteriashinwisteria
提出日時 2017-03-31 16:09:16
言語 Java21
(openjdk 21)
結果
TLE  
実行時間 -
コード長 597 bytes
コンパイル時間 3,102 ms
コンパイル使用メモリ 71,904 KB
実行使用メモリ 60,208 KB
最終ジャッジ日時 2023-09-21 10:40:06
合計ジャッジ時間 9,953 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 117 ms
60,208 KB
testcase_01 AC 118 ms
55,728 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.Arrays;
import java.util.Scanner;

public class Ruijokasan {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int x = s.nextInt(), N = s.nextInt();
		int[] a = new int[N];
		for(int i = 0;i < N;i++){
			a[i] = s.nextInt();
		}
		s.close();
		int t = (int)(Math.pow(10,6) + 3);
		int[] xa = new int[N];
		Arrays.sort(a);
		for(int i = 0;i < N;i++){
			xa[i] = 1;
			for(int j = 0;j < a[i];j++){
				xa[i] *= x;
				if(xa[i] > t){
					xa[i] %= t;
				}
			}
		}
		int sum = 0;
		for(int i:xa){
			sum += i;
		}
		System.out.println(sum%t);

	}

}
0