結果
問題 | No.16 累乗の加算 |
ユーザー |
![]() |
提出日時 | 2016-09-12 22:07:56 |
言語 | Fortran (gFortran 14.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 mainimplicit noneinteger*8::x,N,total,iinteger*8,allocatable::a(:)integer,parameter::modulo=1000003data total/0/read *,x,Nallocate(a(N))read *,ado i=1,Ntotal = total + power(x,a(i))end doprint '(i0)',MOD(total,modulo)containsrecursive function power(x,p) result(y)integer*8::x,y,pinteger,parameter::modulo=1000003if(p.eq.0) theny = 1returnend ify = power(mod(x*x,modulo),p/2)if(MOD(p,2).eq.1) y = mod(y*x,modulo)end function powerend program main