結果
| 問題 |
No.7 プライムナンバーゲーム
|
| コンテスト | |
| ユーザー |
jj
|
| 提出日時 | 2016-07-24 02:41:40 |
| 言語 | Fortran (gFortran 14.2.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 5,000 ms |
| コード長 | 1,179 bytes |
| コンパイル時間 | 260 ms |
| コンパイル使用メモリ | 35,060 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-10-01 15:47:20 |
| 合計ジャッジ時間 | 847 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 17 |
ソースコード
subroutine get_prime(PrimeList, N)
implicit none
integer::i,j,N
integer,parameter::prime=1,nonprime=0
integer,allocatable::isPrime(:), PrimeList(:)
integer,allocatable::numlist(:)
allocate(numlist(N))
allocate(isPrime(N))
isPrime=prime
isPrime(1)=nonprime
isPrime(2)=prime
do i=2, FLOOR(SQRT(REAL(N)))
if(isPrime(i).eq.prime) then
do j=i+i, N, i
isPrime(j) = nonprime
end do
end if
end do
numlist=(/(i,i=1,N)/)
PrimeList=pack(numlist,isPrime(numlist).eq.prime)
end subroutine get_prime
program main
implicit none
interface
subroutine get_prime(PrimeList, N)
integer::N
integer,allocatable::PrimeList(:)
end subroutine get_prime
end interface
integer::N,i,j
integer,parameter::win=1,lose=0
integer,allocatable::W(:),PrimeList(:)
read *,N
allocate(PrimeList(N))
call get_prime(PrimeList, N)
allocate(W(0:2*N))
W(0:1)=win
w(2:2*N)=lose
do i=0, N
if (W(i).eq.win) cycle
do j=1, SIZE(PrimeList)
W(i+PrimeList(j))=win
end do
end do
if(W(N).eq.win) then
print '(a)',"Win"
else
print '(a)',"Lose"
end if
end program main
jj