結果
| 問題 | No.16 累乗の加算 |
| コンテスト | |
| ユーザー |
t8m8⛄️
|
| 提出日時 | 2015-04-04 00:36:54 |
| 言語 | Java (openjdk 25.0.2) |
| 結果 |
AC
|
| 実行時間 | 61 ms / 5,000 ms |
| コード長 | 1,072 bytes |
| 記録 | |
| コンパイル時間 | 2,527 ms |
| コンパイル使用メモリ | 83,200 KB |
| 実行使用メモリ | 46,640 KB |
| 最終ジャッジ日時 | 2026-03-12 18:57:58 |
| 合計ジャッジ時間 | 3,940 ms |
|
ジャッジサーバーID (参考情報) |
judge3_1 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 14 |
ソースコード
//No.16 累乗の加算
import java.util.*;
import java.io.*;
import static java.util.Arrays.*;
import static java.lang.Math.*;
public class No16 {
static final Scanner sc = new Scanner(System.in);
static final PrintWriter out = new PrintWriter(System.out,false);
static void solve() {
int x = sc.nextInt();
int n = sc.nextInt();
long ans = 0;
for (int i=0; i<n; i++) {
ans = (ans + modPow(x,sc.nextInt(),1000003))%1000003;
}
out.println(ans);
}
static long modPow(long x, long n, long m) {
long ret = 1;
while (n > 0) {
if ((n&1) == 1) ret = ret*x %m;
x = x*x %m;
n >>= 1;
}
return ret;
}
public static void main(String[] args) {
long start = System.currentTimeMillis();
solve();
out.flush();
long end = System.currentTimeMillis();
//trace(end-start + "ms");
sc.close();
}
static void trace(Object... o) { System.out.println(deepToString(o));}
}
t8m8⛄️