結果

問題 No.129 お年玉(2)
ユーザー jjjj
提出日時 2016-10-10 23:04:04
言語 Fortran
(gFortran 13.2.0)
結果
AC  
実行時間 307 ms / 5,000 ms
コード長 867 bytes
コンパイル時間 1,468 ms
コンパイル使用メモリ 27,448 KB
実行使用メモリ 389,700 KB
最終ジャッジ日時 2023-08-18 17:44:34
合計ジャッジ時間 9,122 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
21,448 KB
testcase_01 AC 1 ms
4,376 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 101 ms
161,168 KB
testcase_06 AC 212 ms
255,580 KB
testcase_07 AC 230 ms
313,308 KB
testcase_08 AC 138 ms
213,260 KB
testcase_09 AC 206 ms
288,248 KB
testcase_10 AC 238 ms
324,728 KB
testcase_11 AC 131 ms
204,460 KB
testcase_12 AC 189 ms
267,464 KB
testcase_13 AC 198 ms
279,868 KB
testcase_14 AC 190 ms
270,268 KB
testcase_15 AC 146 ms
222,144 KB
testcase_16 AC 174 ms
252,720 KB
testcase_17 AC 223 ms
307,328 KB
testcase_18 AC 206 ms
289,416 KB
testcase_19 AC 224 ms
308,952 KB
testcase_20 AC 224 ms
306,580 KB
testcase_21 AC 307 ms
383,744 KB
testcase_22 AC 143 ms
215,508 KB
testcase_23 AC 265 ms
334,776 KB
testcase_24 AC 238 ms
321,512 KB
testcase_25 AC 128 ms
205,692 KB
testcase_26 AC 132 ms
210,772 KB
testcase_27 AC 130 ms
204,360 KB
testcase_28 AC 292 ms
387,532 KB
testcase_29 AC 1 ms
4,380 KB
testcase_30 AC 1 ms
4,376 KB
testcase_31 AC 1 ms
4,380 KB
testcase_32 AC 1 ms
4,380 KB
testcase_33 AC 1 ms
4,376 KB
testcase_34 AC 1 ms
4,376 KB
testcase_35 AC 3 ms
4,376 KB
testcase_36 AC 3 ms
4,528 KB
testcase_37 AC 2 ms
5,272 KB
testcase_38 AC 21 ms
43,580 KB
testcase_39 AC 33 ms
66,676 KB
testcase_40 AC 109 ms
190,784 KB
testcase_41 AC 57 ms
115,912 KB
testcase_42 AC 25 ms
49,620 KB
testcase_43 AC 24 ms
48,756 KB
testcase_44 AC 293 ms
389,700 KB
testcase_45 AC 14 ms
27,652 KB
testcase_46 AC 37 ms
74,880 KB
testcase_47 AC 258 ms
376,356 KB
testcase_48 AC 125 ms
225,276 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

program main
  implicit none
  integer*8::N,M,amari
  integer*8,parameter::sen=1000
  read *,N,M
  N = N/sen
  amari = MOD(N, M)
  amari = MIN(amari, M-amari)
  M = get_combination(M,amari)
contains
  function get_combination(N,R) result(NCR)
    implicit none
    !pascal triangle
    integer*8,intent(in)::N,R
    integer*8::NCR,i,j
    integer*4,allocatable::pascal(:,:)
    integer*4,parameter::modulo=10**9
!    print *, N, R
    if(R.eq.0) then
       NCR = 1
    else if(R.eq.1) then
       NCR = N
    else
       allocate(pascal(0:N, 0:N))
       pascal = 0
       pascal(0,0) =1

       do i=1,N
          do j=0,i
             pascal(j,i) = MOD(pascal(j-1,i-1) + pascal(j,i-1),modulo)
          end do
!          print *,i, pascal(:,i)
       end do
       NCR = pascal(R,N)
    end if
    print '(i0)', NCR
  end function get_combination
end program main
0