結果

問題 No.129 お年玉(2)
コンテスト
ユーザー jj
提出日時 2016-10-10 17:59:05
言語 Fortran
(gFortran 15.2.0)
コンパイル:
gfortran _filename_ -O2 -o ./a.out
実行:
./a.out
結果
TLE  
実行時間 -
コード長 608 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 232 ms
コンパイル使用メモリ 36,984 KB
実行使用メモリ 8,960 KB
最終ジャッジ日時 2026-05-16 04:55:23
合計ジャッジ時間 13,021 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample -- * 3
other TLE * 1 -- * 45
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

program main
  implicit none
  integer*8::N,M,amari
  integer*8,parameter::sen=1000
  read *,N,M
  N = N/sen
  amari = MOD(N, M)
  print '(i0)', get_combination(M, MIN(amari, M-amari))
contains
  recursive function get_combination(N,R) result(NCR)
    integer*8::N,R,NCR
    integer*8,parameter::modular=10**9
    if(R.eq.0) then
       NCR = 1
    else if(R.eq.1) then
       NCR = N
    else if(N-R.lt.R) then
       NCR = get_combination(N, N-R)
    else
       NCR = get_combination(N-1,R) + get_combination(N-1,R-1)
    end if
    NCR = MOD(NCR, modular)
  end function get_combination
end program main
0