結果

問題 No.16 累乗の加算
ユーザー jp_ste
提出日時 2016-02-12 14:47:21
言語 Java
(openjdk 23)
結果
TLE  
実行時間 -
コード長 430 bytes
コンパイル時間 2,107 ms
コンパイル使用メモリ 73,984 KB
実行使用メモリ 61,140 KB
最終ジャッジ日時 2024-09-22 04:11:06
合計ジャッジ時間 9,001 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 2 TLE * 1 -- * 11
権限があれば一括ダウンロードができます

ソースコード

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