結果

問題 No.16 累乗の加算
ユーザー 37zigen37zigen
提出日時 2018-04-07 15:50:38
言語 Fortran
(gFortran 13.2.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 594 bytes
コンパイル時間 944 ms
コンパイル使用メモリ 26,956 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-08 18:13:16
合計ジャッジ時間 1,876 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

module mdl
    implicit none
    integer(kind=8),parameter::m=1000003
contains

    integer(kind=8) function pow(a,pwr)
        implicit none
        integer(kind=8),value::a,pwr
        pow=1
        do while(pwr>0)
            if(mod(pwr,2)==1)pow=mod(pow*a,m)
            a=mod(a*a,m)
            pwr=pwr/2
        end do
    end function
end module



program main
    use mdl
    implicit none
    integer(kind=8)::i,j,l,r,x,y,n
    integer(kind=8)::ret=0,a(100)
    read(*,*)x,n
    read*,(a(i),i=1,n)
    do i=1,n
        ret=mod(ret+pow(x,a(i)),m)
    end do
    print*,ret
end program
0