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) integer(kind=8)::check(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.(src0)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