結果
問題 | No.458 異なる素数の和 |
ユーザー | Eliza_0x |
提出日時 | 2018-05-04 08:00:28 |
言語 | Scala(Beta) (3.4.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 752 bytes |
コンパイル時間 | 8,628 ms |
コンパイル使用メモリ | 266,032 KB |
実行使用メモリ | 134,492 KB |
最終ジャッジ日時 | 2023-09-12 18:56:05 |
合計ジャッジ時間 | 15,381 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | TLE | - |
testcase_01 | -- | - |
testcase_02 | -- | - |
testcase_03 | -- | - |
testcase_04 | -- | - |
testcase_05 | -- | - |
testcase_06 | -- | - |
testcase_07 | -- | - |
testcase_08 | -- | - |
testcase_09 | -- | - |
testcase_10 | -- | - |
testcase_11 | -- | - |
testcase_12 | -- | - |
testcase_13 | -- | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
testcase_27 | -- | - |
testcase_28 | -- | - |
testcase_29 | -- | - |
testcase_30 | -- | - |
ソースコード
object Main extends App { val scan = new java.util.Scanner(System.in) val numbers = Array.fill(25000)(true) for ( i <- 2 until 25000 ) for ( l <- 2 until 25000; if i*l < 25000 ) numbers(i*l) = false val primes = (0 to 25000).zip(numbers).filter(_._2).map(_._1).drop(2).toList val n = scan.next().toInt var memo = Array.fill(1+primes.length, 20000)(-1) memo(0)(0) = 0 for ( (i, n) <- (1 to primes.length).zip(primes) ) { for ( l <- 0 until 20000 ) { memo(i)(l) = math.max(memo(i-1)(l), memo(i)(l)) if (memo(i-1)(l) != -1 && l+n < 20000) { memo(i)(l+n) = math.max(memo(i-1)(l)+1, memo(i)(l+n)) if (l+n==4) println("prime: " ++ n.toString) } } } println(memo(primes.length)(n)) }