結果
| 問題 | No.16 累乗の加算 |
| コンテスト | |
| ユーザー |
kohaku_kohaku
|
| 提出日時 | 2016-11-17 22:56:29 |
| 言語 | Java (openjdk 25.0.2) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 656 bytes |
| 記録 | |
| コンパイル時間 | 2,365 ms |
| コンパイル使用メモリ | 81,636 KB |
| 実行使用メモリ | 42,160 KB |
| 最終ジャッジ日時 | 2026-05-20 15:03:13 |
| 合計ジャッジ時間 | 3,565 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 2 WA * 12 |
ソースコード
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
long x = sc.nextLong();
int N = sc.nextInt();
long mod = 1000003;
long sum=0;
for(int i=0; i<N; i++){
long a = sc.nextInt();
sum+=pow(x,a,mod);
}
System.out.println(sum);
}
static long pow(long x, long n, long m){
if(n==0){
return 1;
}else if(n%2==1){
long r = x*pow(x*x,n/2,m)%m;
return r;
}else{
long r = pow(x*x,n/2,m)%m;
return r;
}
}
}
kohaku_kohaku