結果

問題 No.47 ポケットを叩くとビスケットが2倍
コンテスト
ユーザー nnsnico
提出日時 2019-05-01 21:27:10
言語 Scala(Beta)
(3.8.1)
コンパイル:
scalac _filename_
実行:
java -cp .:/home/linuxbrew/.linuxbrew/Cellar/scala/3.8.1/libexec/maven2/org/scala-lang/scala3-library_3/3.8.1/scala3-library_3-3.8.1.jar:/home/linuxbrew/.linuxbrew/Cellar/scala/3.8.1/libexec/maven2/org/scala-lang/scala-library/3.8.1/scala-library-3.8.1.jar _class_
結果
AC  
実行時間 495 ms / 5,000 ms
コード長 313 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 13,553 ms
コンパイル使用メモリ 253,276 KB
実行使用メモリ 65,492 KB
最終ジャッジ日時 2026-03-09 16:48:24
合計ジャッジ時間 23,066 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

object Main extends App {
  val n: Int = scala.io.StdIn.readInt()

  def stream(n: Int): Stream[Int] = Stream.cons(n, stream(n + n))

  // 0,1,2,4 ..
  val mugen: Stream[Int] = (0 #:: stream(1)).map(_ * 2)

  val targetValue = mugen.find(_ > n - 1)

  println(if (n <= 1) 0 else mugen.indexOf(targetValue.get))
}
0