結果

問題 No.16 累乗の加算
ユーザー core123core123
提出日時 2019-05-07 10:03:53
言語 Java21
(openjdk 21)
結果
AC  
実行時間 160 ms / 5,000 ms
コード長 576 bytes
コンパイル時間 4,213 ms
コンパイル使用メモリ 71,820 KB
実行使用メモリ 55,988 KB
最終ジャッジ日時 2023-09-14 16:23:38
合計ジャッジ時間 4,987 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 128 ms
55,584 KB
testcase_01 AC 128 ms
55,520 KB
testcase_02 AC 160 ms
55,788 KB
testcase_03 AC 142 ms
55,944 KB
testcase_04 AC 145 ms
55,572 KB
testcase_05 AC 145 ms
55,740 KB
testcase_06 AC 156 ms
55,700 KB
testcase_07 AC 151 ms
55,784 KB
testcase_08 AC 155 ms
55,532 KB
testcase_09 AC 156 ms
55,788 KB
testcase_10 AC 154 ms
55,496 KB
testcase_11 AC 125 ms
55,676 KB
testcase_12 AC 151 ms
55,584 KB
testcase_13 AC 134 ms
55,988 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc=new Scanner(System.in);
		int x=sc.nextInt();
		int n=sc.nextInt();
		int a[] = new int[n];
		for(int i=0;i<n;i++) {
			a[i]=sc.nextInt();
		}
		BigInteger ans=BigInteger.ZERO;
		BigInteger MOD=BigInteger.valueOf(1000003);
		BigInteger xx=BigInteger.valueOf(x);
		for(int i=0;i<n;i++) {
			ans=ans.add(xx.modPow(BigInteger.valueOf(a[i]), MOD));
			ans=ans.mod(MOD);
		}
		System.out.println(ans);
	}

}
0