結果

問題 No.16 累乗の加算
ユーザー GrenacheGrenache
提出日時 2015-11-03 14:26:38
言語 Java21
(openjdk 21)
結果
AC  
実行時間 135 ms / 5,000 ms
コード長 681 bytes
コンパイル時間 3,133 ms
コンパイル使用メモリ 71,684 KB
実行使用メモリ 56,248 KB
最終ジャッジ日時 2023-09-08 11:47:35
合計ジャッジ時間 5,824 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 125 ms
55,720 KB
testcase_01 AC 126 ms
55,756 KB
testcase_02 AC 135 ms
56,092 KB
testcase_03 AC 131 ms
55,952 KB
testcase_04 AC 129 ms
56,248 KB
testcase_05 AC 131 ms
56,036 KB
testcase_06 AC 134 ms
55,928 KB
testcase_07 AC 134 ms
55,760 KB
testcase_08 AC 135 ms
55,384 KB
testcase_09 AC 134 ms
55,964 KB
testcase_10 AC 133 ms
55,596 KB
testcase_11 AC 126 ms
55,692 KB
testcase_12 AC 134 ms
55,628 KB
testcase_13 AC 132 ms
55,868 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;


public class Main_yukicoder16 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        final int MOD = 1000003;
        int x = sc.nextInt();
        int n = sc.nextInt();
        
        long ret = 0;
        for (int i = 0; i < n; i++) {
        	int a = sc.nextInt();
        	long tmp = x;
        	long tmp2 = 1;
        	while (a > 0) {
        		if (a % 2 == 1) {
        			tmp2 = tmp2 * tmp % MOD;
        		}
        		tmp = tmp * tmp % MOD;
        		a /= 2;
        	}
        	
        	ret = (ret + tmp2) % MOD;
        }

        System.out.println(ret);
        
        sc.close();
    }
}
0