module mdl contains logical function isPrime(n) integer(kind=8)::n integer::i,j,k do i=2,n if(i*i>n)exit if(mod(n,i)==0)then isPrime=.false. return end if end do isPrime=.true. end function end module module random_mdl implicit none integer(kind=8),private::m=1000000007,a=432432,b=440823,seed=432 contains integer(kind=8) function next_seed() seed=mod(a*seed+b,m) next_seed=mod(seed,1000000)+1 end function end module module list integer(kind=8),private::a(100000),p=1 contains subroutine add(v) integer(kind=8)::v a(p)=v p=p+1 end subroutine function get(i) integer(kind=8)::get integer(kind=4)::i get=a(i) end function end module program main use mdl use random_mdl use list implicit none integer(kind=8)::a(6) integer::i,j,k integer::n,m,ans(10000) loop1:do do i=1,6 a(i)=next_seed() end do do i=1,6,2 if(.not.isPrime(a(i)+a(i+1)))cycle loop1 end do do i=1,6 do j=i+1,6 if(mod(i,2)==1 .and. i+1==j)cycle if(isPrime(a(i)+a(j)))then cycle loop1 end if end do end do exit end do loop1 read*,n m=(100+n/100)+(10+mod(n,100)/10)+(1+mod(n,10)) print*,m do i=1,100 call add(a(1)) end do do i=1,n/100 call add(a(2)) end do do i=1,10 call add(a(3)) end do do i=1,mod(n,100)/10 call add(a(4)) end do do i=1,1 call add(a(5)) end do do i=1,mod(n,10) call add(a(6)) end do do i=1,m write(*,'(i0)',advance='no')get(i) if(i==m)then print*,"" else write(*,'(a)',advance='no')" " end if end do end program