結果

問題 No.16 累乗の加算
ユーザー kou6839kou6839
提出日時 2014-11-23 10:52:03
言語 Java21
(openjdk 21)
結果
AC  
実行時間 137 ms / 5,000 ms
コード長 491 bytes
コンパイル時間 2,140 ms
コンパイル使用メモリ 70,712 KB
実行使用メモリ 55,928 KB
最終ジャッジ日時 2023-09-08 11:30:29
合計ジャッジ時間 4,654 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 122 ms
55,912 KB
testcase_01 AC 126 ms
55,596 KB
testcase_02 AC 134 ms
55,792 KB
testcase_03 AC 128 ms
55,884 KB
testcase_04 AC 132 ms
55,928 KB
testcase_05 AC 130 ms
55,644 KB
testcase_06 AC 133 ms
53,740 KB
testcase_07 AC 131 ms
55,756 KB
testcase_08 AC 136 ms
55,920 KB
testcase_09 AC 136 ms
55,728 KB
testcase_10 AC 136 ms
55,704 KB
testcase_11 AC 126 ms
55,644 KB
testcase_12 AC 137 ms
55,644 KB
testcase_13 AC 136 ms
55,920 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
 

public class Main {
	static long kuri(long x,long a){
		if(a==0) return 1;
		long res = kuri(x*x%1000003,a/2);
		if(a%2==1) res=res*x;
		return res%1000003;
	}
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long x = sc.nextLong();
		long n = sc.nextLong();
		long ans=0;
		for(int i=0;i<n;i++){
			int aa=sc.nextInt();
			long temp=kuri(x,aa);
			ans+=temp%1000003;
		}
		System.out.println(ans%1000003);
	}
}	
0