結果

問題 No.237 作図可能性
ユーザー ともきともき
提出日時 2015-07-06 00:06:38
言語 Scala(Beta)
(3.4.0)
結果
AC  
実行時間 1,053 ms / 2,000 ms
コード長 677 bytes
コンパイル時間 10,147 ms
コンパイル使用メモリ 251,360 KB
実行使用メモリ 64,444 KB
最終ジャッジ日時 2023-09-11 11:33:25
合計ジャッジ時間 42,888 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,022 ms
63,620 KB
testcase_01 AC 1,027 ms
64,208 KB
testcase_02 AC 1,036 ms
64,200 KB
testcase_03 AC 1,018 ms
64,208 KB
testcase_04 AC 1,025 ms
64,168 KB
testcase_05 AC 1,018 ms
64,228 KB
testcase_06 AC 1,028 ms
64,084 KB
testcase_07 AC 1,031 ms
64,300 KB
testcase_08 AC 1,040 ms
64,236 KB
testcase_09 AC 1,046 ms
64,292 KB
testcase_10 AC 1,048 ms
64,352 KB
testcase_11 AC 1,020 ms
64,004 KB
testcase_12 AC 1,016 ms
63,796 KB
testcase_13 AC 1,043 ms
64,112 KB
testcase_14 AC 1,038 ms
64,272 KB
testcase_15 AC 1,040 ms
64,100 KB
testcase_16 AC 1,036 ms
64,176 KB
testcase_17 AC 1,048 ms
64,276 KB
testcase_18 AC 1,041 ms
64,188 KB
testcase_19 AC 1,053 ms
64,320 KB
testcase_20 AC 1,041 ms
64,276 KB
testcase_21 AC 1,030 ms
64,064 KB
testcase_22 AC 1,050 ms
64,268 KB
testcase_23 AC 1,038 ms
64,072 KB
testcase_24 AC 1,031 ms
64,304 KB
testcase_25 AC 1,028 ms
64,264 KB
testcase_26 AC 1,042 ms
64,444 KB
testcase_27 AC 1,044 ms
64,152 KB
testcase_28 AC 1,014 ms
64,040 KB
testcase_29 AC 1,027 ms
64,192 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import scala.io.StdIn.readLine
import scala.collection.mutable.PriorityQueue
import scala.annotation.tailrec


object Main {
  def solve(n : Long) : Int = {
    val fermat_numbers = List[Long](3, 5, 17, 257, 65537)
    def big(c : Set[Long],k : Long) : Set[Long] = {
      c.withFilter(_*k <= n).map(_*k) ++ c
    }
    val init = (0l to Math.ceil(Math.log(n)/Math.log(2)).toLong).
                 map((k) => Math.round(Math.pow(2,k)).toLong).toSet
    val drawables_in_n = fermat_numbers.foldLeft(init)(big(_,_)).filter((i) => 3 <= i && i <= n)
    drawables_in_n.size
  }
  def main(args : Array[String]) : Unit = {
    val n = readLine().toLong
    println(solve(n))
  }
}
0