結果

問題 No.47 ポケットを叩くとビスケットが2倍
ユーザー nnsniconnsnico
提出日時 2019-05-01 21:27:10
言語 Scala(Beta)
(3.4.0)
結果
AC  
実行時間 993 ms / 5,000 ms
コード長 313 bytes
コンパイル時間 12,059 ms
コンパイル使用メモリ 249,368 KB
実行使用メモリ 62,292 KB
最終ジャッジ日時 2023-09-14 16:17:02
合計ジャッジ時間 36,116 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 937 ms
62,036 KB
testcase_01 AC 944 ms
62,044 KB
testcase_02 AC 948 ms
62,132 KB
testcase_03 AC 993 ms
61,940 KB
testcase_04 AC 948 ms
62,160 KB
testcase_05 AC 940 ms
61,760 KB
testcase_06 AC 941 ms
61,956 KB
testcase_07 AC 943 ms
62,016 KB
testcase_08 AC 947 ms
61,836 KB
testcase_09 AC 944 ms
62,264 KB
testcase_10 AC 943 ms
62,048 KB
testcase_11 AC 943 ms
61,868 KB
testcase_12 AC 937 ms
61,952 KB
testcase_13 AC 933 ms
61,892 KB
testcase_14 AC 931 ms
61,956 KB
testcase_15 AC 945 ms
61,952 KB
testcase_16 AC 933 ms
61,980 KB
testcase_17 AC 944 ms
62,292 KB
testcase_18 AC 954 ms
61,952 KB
testcase_19 AC 956 ms
61,956 KB
testcase_20 AC 935 ms
61,836 KB
testcase_21 AC 916 ms
62,000 KB
testcase_22 AC 939 ms
61,972 KB
testcase_23 AC 949 ms
61,952 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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