結果

問題 No.690 E869120 and Constructing Array 4
ユーザー 37zigen37zigen
提出日時 2018-05-19 16:14:23
言語 Fortran
(gFortran 13.2.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 1,218 bytes
コンパイル時間 159 ms
コンパイル使用メモリ 28,184 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-10 23:43:45
合計ジャッジ時間 1,480 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 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,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 1 ms
4,376 KB
testcase_20 AC 1 ms
4,380 KB
testcase_21 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

program main
    implicit none
    integer(kind=8)::K,M=0,src=1,dst=32,addV=31,c=0
    integer::i,j
    logical::g(32,32)
    read*,K
    if(K==0)then
        print*,"32 0"
        return
    end if
    do i=1,32
        do j=1,32
            g(i,j)=.false.
        end do
    end do
    do while(lshift(1,c+1)<=K)
        c=c+1
    end do
    do i=1,32
        do j=i+1,32
            if(i/=src.and.i/=dst.and..not.(src<i.and.i<=src+c))cycle
            if(j/=src.and.j/=dst.and..not.(src<j.and.j<=src+c))cycle
            g(i,j)=.true.
            M=M+1
        end do
    end do
    K=K-lshift(1,c)
    if(K>0)then
        g(addV,dst)=.true.
        M=M+1
        do i=src+c,src,-1
            if(K==0)exit
            if (K-lshift(1,i-src-1)>= 0)then
                K=K-lshift(1,i-src-1)
                g(i,addV)=.true.
                M=M+1
            end if
        end do
    end if
    print*,32," ",M
    do i=1,32
        do j=i+1,32
            if(g(i,j))print*,i,j
        end do
    end do
!    do i=1,32
!        check(i)=0
!    end do
!    check(1)=1
!    do i=1,32
!        do j=i+1,32
!            if(g(i,j))check(j)=check(j)+check(i)
!        end do
!    end do
!    print*,check(dst)
end program
0