結果

問題 No.407 鴨等素数間隔列の数え上げ
ユーザー jjjj
提出日時 2016-08-05 22:59:58
言語 Fortran
(gFortran 13.2.0)
結果
AC  
実行時間 50 ms / 1,000 ms
コード長 932 bytes
コンパイル時間 1,352 ms
コンパイル使用メモリ 28,264 KB
実行使用メモリ 22,036 KB
最終ジャッジ日時 2023-08-22 04:02:22
合計ジャッジ時間 2,898 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,384 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 5 ms
4,504 KB
testcase_20 AC 14 ms
8,356 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 AC 1 ms
4,376 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 1 ms
4,380 KB
testcase_25 AC 25 ms
12,316 KB
testcase_26 AC 1 ms
4,380 KB
testcase_27 AC 1 ms
4,380 KB
testcase_28 AC 1 ms
4,376 KB
testcase_29 AC 1 ms
4,380 KB
testcase_30 AC 1 ms
4,376 KB
testcase_31 AC 1 ms
4,380 KB
testcase_32 AC 11 ms
7,320 KB
testcase_33 AC 50 ms
22,028 KB
testcase_34 AC 48 ms
22,036 KB
testcase_35 AC 22 ms
11,420 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

subroutine get_prime(isPrime, N)
  implicit none
  integer::i,j,N
  integer,parameter::prime=1,nonprime=0
  integer,allocatable::isPrime(:)

  isPrime=prime
  isPrime(1)=nonprime

  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

end subroutine get_prime

program main
  interface
     subroutine get_prime(isPrime, N)
       integer::N
       integer,allocatable::isPrime(:)
     end subroutine get_prime
  end interface
  integer::primelimit
  integer*8::total
  integer,allocatable::isPrime(:)

  read *, N,L

  primelimit = L/(N-1)

  if(primelimit.lt.2) then
     print '(i0)', 0
     return
  end if

  allocate(isPrime(primelimit))
  call get_prime(isPrime, primelimit)

  total = 0
  do i=1, primelimit
     if(isPrime(i).eq.0) cycle
     total = total + (L-(N-1)*i) + 1
  end do

  print '(i0)', total

end program
0