結果

問題 No.36 素数が嫌い!
ユーザー jj
提出日時 2016-10-10 00:05:34
言語 Fortran
(gFortran 14.2.0)
結果
RE  
実行時間 -
コード長 524 bytes
コンパイル時間 513 ms
コンパイル使用メモリ 32,768 KB
実行使用メモリ 583,260 KB
最終ジャッジ日時 2024-11-22 00:37:40
合計ジャッジ時間 1,870 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 1 WA * 2 RE * 22 MLE * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

program main
  implicit none
  integer*8::N,i,j
  integer*8::upper
  integer*8,allocatable::isPrime(:)
  read *,N
  if(N.eq.1) then
     print '(a)', "NO"
     return
  end if

  allocate(isPrime(N))
  isPrime = 1
  upper = FLOOR(SQRT(REAL(N)))

  do i=2, FLOOR(SQRT(REAL(N)))
     if(isPrime(i).eq.1) then
        if(MOD(N,i).eq.0) then
           print '(a)', "YES"
           return
        end if
        do j=i+i, N, i
           isPrime(j) = 0
        end do
     end if
  end do

  print '(a)', "NO"
end program main
0