結果
| 問題 |
No.689 E869120 and Constructing Array 3
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-05-19 06:30:32 |
| 言語 | Fortran (gFortran 14.2.0) |
| 結果 |
AC
|
| 実行時間 | 18 ms / 1,000 ms |
| コード長 | 1,992 bytes |
| コンパイル時間 | 1,178 ms |
| コンパイル使用メモリ | 35,200 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-06-28 14:19:21 |
| 合計ジャッジ時間 | 2,806 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 13 |
ソースコード
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