結果
問題 |
No.407 鴨等素数間隔列の数え上げ
|
ユーザー |
![]() |
提出日時 | 2016-08-05 22:59:58 |
言語 | Fortran (gFortran 14.2.0) |
結果 |
AC
|
実行時間 | 62 ms / 1,000 ms |
コード長 | 932 bytes |
コンパイル時間 | 2,959 ms |
コンパイル使用メモリ | 32,896 KB |
実行使用メモリ | 21,708 KB |
最終ジャッジ日時 | 2024-12-15 21:53:06 |
合計ジャッジ時間 | 4,034 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 5 |
other | AC * 31 |
ソースコード
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