結果

問題 No.1243 約数加算
ユーザー yudedakoyudedako
提出日時 2022-01-26 16:31:07
言語 Scala(Beta)
(3.4.0)
結果
AC  
実行時間 1,077 ms / 2,000 ms
コード長 637 bytes
コンパイル時間 14,248 ms
コンパイル使用メモリ 259,016 KB
実行使用メモリ 62,824 KB
最終ジャッジ日時 2023-08-24 21:34:42
合計ジャッジ時間 26,263 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 934 ms
62,304 KB
testcase_01 AC 942 ms
61,956 KB
testcase_02 AC 945 ms
62,156 KB
testcase_03 AC 947 ms
62,324 KB
testcase_04 AC 994 ms
62,204 KB
testcase_05 AC 1,053 ms
62,704 KB
testcase_06 AC 1,077 ms
62,668 KB
testcase_07 AC 1,006 ms
62,720 KB
testcase_08 AC 1,057 ms
62,712 KB
testcase_09 AC 944 ms
62,824 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import scala.annotation.tailrec
import scala.collection.mutable.ArrayBuffer
import scala.io.StdIn.*
import scala.math.*

@main def main =
  val testCase = readLine().toInt
  for _ <- 0 until testCase do
    val Array(a, b) = readLine().split(' ').map(_.toLong)
    var current = a
    val op = ArrayBuffer[Long]()
    for i <- 0 until 60 do
      val d = 1L << i
      if (current & d) != 0L && current + d <= b then
        current += d
        op.addOne(d)
    for i <- 59 to 0 by -1 do
      val d = 1L << i
      if current + d <= b then
        current += d
        op.addOne(d)
    println(op.length)
    println(op.mkString(" "))
0