結果

問題 No.16 累乗の加算
ユーザー NaruY
提出日時 2016-12-09 20:44:01
言語 Java
(openjdk 23)
結果
RE  
実行時間 -
コード長 808 bytes
コンパイル時間 2,742 ms
コンパイル使用メモリ 76,504 KB
実行使用メモリ 44,424 KB
最終ジャッジ日時 2024-11-28 19:54:00
合計ジャッジ時間 4,388 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other RE * 14
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;
 
public class Main {
    public static void main (String[] args) throws IOException
    {
    	Scanner sc = new Scanner(System.in);
    	int x = sc.nextInt();
    	int N = sc.nextInt();
    	
    	int a[] = new int [N+10];
    	long s[] = new long [100000002];
    	long ans = 0;
    	
    	
     	for (int i = 1 ; i <= N ; i++){
    	    a[i] = sc.nextInt();
    	}
    	
    	s[0] = 1;
    	s[1] = x;
    	for (int i=2 ;i <= 100000000 ;i++){
    		s[i] = (s[i-1] * x) % 1000003;
    	}
    	
    	for (int j=1 ; j <= N ; j++){
    		ans = (ans + s[a[j]]) % 1000003 ;
    	}
    	
    	System.out.println(ans);
    }

}
    
0