結果
| 問題 | No.16 累乗の加算 |
| コンテスト | |
| ユーザー |
jj
|
| 提出日時 | 2016-09-12 22:07:56 |
| 言語 | Fortran (gFortran 15.2.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 548 bytes |
| 記録 | |
| コンパイル時間 | 1,163 ms |
| コンパイル使用メモリ | 33,280 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-06-26 05:16:40 |
| 合計ジャッジ時間 | 878 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 14 |
ソースコード
program main
implicit none
integer*8::x,N,total,i
integer*8,allocatable::a(:)
integer,parameter::modulo=1000003
data total/0/
read *,x,N
allocate(a(N))
read *,a
do i=1,N
total = total + power(x,a(i))
end do
print '(i0)',MOD(total,modulo)
contains
recursive function power(x,p) result(y)
integer*8::x,y,p
integer,parameter::modulo=1000003
if(p.eq.0) then
y = 1
return
end if
y = power(mod(x*x,modulo),p/2)
if(MOD(p,2).eq.1) y = mod(y*x,modulo)
end function power
end program main
jj