結果

問題 No.639 An Ordinary Sequence
ユーザー 37zigen
提出日時 2018-04-19 21:41:21
言語 Fortran
(gFortran 14.2.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 690 bytes
コンパイル時間 312 ms
コンパイル使用メモリ 41,600 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2025-01-02 02:29:46
合計ジャッジ時間 1,121 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

module mdl
    integer*8::f(0:40,0:40)
contains

    subroutine build()
        do i=0,40
            do j=0,40
                f(i,j)=-1
            end do
        end do
    end subroutine

    recursive function calc(a,b,cur)result(res)
        integer::a,b
        integer*8::cur,res
        if(f(a,b)/=-1)then
            res=f(a,b)
            return
        end if
        if(cur==0)then
            f(a,b)=1
            res=1
            return
        end if
        res=calc(a+1,b,cur/3)+calc(a,b+1,cur/5)
        f(a,b)=res
    end function

end module


program main
    use mdl
    implicit none
    integer*8::n
    read*,n
    call build()
    print*,calc(0,0,n)
end program
0