結果
問題 | No.16 累乗の加算 |
ユーザー |
![]() |
提出日時 | 2014-11-23 10:52:03 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 147 ms / 5,000 ms |
コード長 | 491 bytes |
コンパイル時間 | 1,967 ms |
コンパイル使用メモリ | 74,092 KB |
実行使用メモリ | 41,600 KB |
最終ジャッジ日時 | 2024-06-26 04:47:29 |
合計ジャッジ時間 | 4,810 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 14 |
ソースコード
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); } }