結果

問題 No.16 累乗の加算
ユーザー jp_stejp_ste
提出日時 2016-02-12 14:47:21
言語 Java21
(openjdk 21)
結果
TLE  
実行時間 -
コード長 430 bytes
コンパイル時間 1,714 ms
コンパイル使用メモリ 73,920 KB
実行使用メモリ 56,196 KB
最終ジャッジ日時 2023-10-22 02:34:57
合計ジャッジ時間 9,366 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 100 ms
56,196 KB
testcase_01 AC 101 ms
56,108 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 scan = new Scanner(System.in);
		long ans = 0;
		
		int x = scan.nextInt();
		int N = scan.nextInt();
		for(int i=0; i<N; i++) {
			int a = scan.nextInt();
			ans += pow(x,a);
		}
		System.out.println(ans);	
	}
	
	static int pow(int x, int a) {
		int v = 1;
		for(int i=0; i<a; i++) {
			v = (v * x) % 1000003;
		}
		return v;
	}
}
0