結果
問題 | No.385 カップ麺生活 |
ユーザー |
![]() |
提出日時 | 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 noneinteger::i,j,Ninteger,parameter::prime=1,nonprime=0integer,allocatable::isPrime(:)isPrime=primeisPrime(1)=nonprimedo i=2, FLOOR(SQRT(REAL(N)))if(isPrime(i).eq.prime) thendo j=i+i, N, iisPrime(j) = nonprimeend doend ifend doend subroutine get_primeprogram mainimplicit noneinterfacesubroutine get_prime(isPrime, N)integer::Ninteger,allocatable::isPrime(:)end subroutine get_primeend interfaceinteger::M,N,i,j,suminteger,allocatable::C(:),isPrime(:)integer::memo(-1000:10000)data memo/11001*0/read *,M, Nallocate(C(N))allocate(isPrime(2:M))read *, Cmemo(M) = 1do i=M, 1, -1if(memo(i).eq.0) cycledo j=1, Nmemo(i-C(j)) = MAX(memo(i-C(j)),memo(i) + 1)end doend docall get_prime(isPrime, M)sum = M/MINVAL(C)do i=2, Mif(isPrime(i).eq.0) cycleif(memo(i).eq.0) cyclesum = sum + (memo(i)-1)end doprint '(i0)', sumend program main