結果

問題 No.140 みんなで旅行
ユーザー 37zigen37zigen
提出日時 2018-04-21 18:44:22
言語 Fortran
(gFortran 13.2.0)
結果
AC  
実行時間 1,174 ms / 5,000 ms
コード長 1,083 bytes
コンパイル時間 156 ms
コンパイル使用メモリ 28,172 KB
実行使用メモリ 7,400 KB
最終ジャッジ日時 2023-09-09 12:22:13
合計ジャッジ時間 7,209 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 10 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 1,174 ms
7,400 KB
testcase_12 AC 7 ms
4,376 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 1,136 ms
7,340 KB
testcase_15 AC 1,105 ms
7,380 KB
testcase_16 AC 265 ms
6,544 KB
testcase_17 AC 70 ms
6,296 KB
testcase_18 AC 754 ms
6,884 KB
testcase_19 AC 882 ms
7,028 KB
testcase_20 AC 46 ms
4,376 KB
testcase_21 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

program main
    implicit none
    integer*8::n,f(0:1,0:560,0:560),i,j,k,ans
    integer*8,parameter::mo=1000000007
    read*,n
    do i=0,n
        do j=0,n
            f(0,i,j)=0
        end do
    end do
    f(0,0,0)=1
    block
        integer::cur,ne
        do i=1,n
            cur=mod(i-1,2)
            ne=mod(cur+1,2)
            do j=0,j
                do k=0,n
                    f(ne,j,k)=0
                end do
            end do
            do j=0,n
                do k=0,n
                    if(f(cur,j,k)==0)cycle
                    f(ne,j,k)=mod(f(ne,j,k)+f(cur,j,k)*j*j+f(cur,j,k)*k*(k-1)+f(cur,j,k)*k*j*2,mo)
                    f(ne,j+1,k)=mod(f(ne,j+1,k)+f(cur,j,k),mo)
                    f(ne,j,k+1)=mod(f(ne,j,k+1)+f(cur,j,k)*(j+k)*2,mo)
                    f(ne,j,k+2)=mod(f(ne,j,k+2)+f(cur,j,k),mo)
                    if(k>0)f(ne,j+1,k-1)=mod(f(ne,j+1,k-1)+f(cur,j,k)*k,mo)
                end do
            end do
        end do
    end block

    ans=0
    do i=1,n
        ans=mod(ans+f(mod(n,2),i,0),mo)
    end do
    print*,ans
end program
0