結果
| 問題 |
No.385 カップ麺生活
|
| コンテスト | |
| ユーザー |
jj
|
| 提出日時 | 2016-08-04 23:36:47 |
| 言語 | Fortran (gFortran 14.2.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 1,073 bytes |
| コンパイル時間 | 489 ms |
| コンパイル使用メモリ | 33,608 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-10-04 22:49:46 |
| 合計ジャッジ時間 | 1,457 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 32 |
ソースコード
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
implicit none
interface
subroutine get_prime(isPrime, N)
integer::N
integer,allocatable::isPrime(:)
end subroutine get_prime
end interface
integer::M,N,i,j,sum
integer,allocatable::C(:),isPrime(:)
integer::memo(-1000:10000)
data memo/11001*0/
read *,M, N
allocate(C(N))
allocate(isPrime(2:M))
read *, C
memo(M) = 1
do i=M, 1, -1
if(memo(i).eq.0) cycle
do j=1, N
memo(i-C(j)) = MAX(memo(i-C(j)),memo(i) + 1)
end do
end do
call get_prime(isPrime, M)
sum = M/MINVAL(C)
do i=2, M
if(isPrime(i).eq.0) cycle
if(memo(i).eq.0) cycle
sum = sum + (memo(i)-1)
end do
print '(i0)', sum
end program main
jj