結果

問題 No.294 SuperFizzBuzz
ユーザー koba-e964koba-e964
提出日時 2015-12-03 10:38:02
言語 Scala(Beta)
(3.4.0)
結果
WA  
実行時間 -
コード長 849 bytes
コンパイル時間 10,361 ms
コンパイル使用メモリ 267,488 KB
実行使用メモリ 63,640 KB
最終ジャッジ日時 2023-09-11 22:01:41
合計ジャッジ時間 27,836 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 968 ms
63,640 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 1,014 ms
62,780 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

/*
 * Reference: http://lizan.asia/blog/2012/12/11/scala-competitive/
 */

object Main extends App {
  import java.{util => ju}
  import scala.annotation._
  import scala.collection._
  import scala.collection.{mutable => mu}
  import scala.collection.JavaConverters._
  import scala.math._

  val sc = new ju.Scanner(System.in)
  def calc(n : Int) : (Long, Int) = {
    var t : Long = 1
    var l : Int = 1
    var rem : Int = n
    while (true) {
      if (t >>> l != 0) {
        t = 1
        l += 1
      } else if (java.lang.Long.bitCount(t) % 3 != 0) {
        t += 2
      } else if (rem == 0) return (t, l)
      else {
        t += 2
        rem -= 1
      }
    }
    return (0,0)
  }
  val n = sc.nextInt
  val (res, len) = calc(n - 1)
  val str = (0 until len).map(i => if ((res & (1 << i)) != 0) "5" else "3").mkString
  println(str)
}
0