結果

問題 No.1738 What's in the box?
ユーザー yudedakoyudedako
提出日時 2022-01-25 13:25:40
言語 Scala(Beta)
(3.4.0)
結果
AC  
実行時間 988 ms / 2,000 ms
コード長 472 bytes
コンパイル時間 18,064 ms
コンパイル使用メモリ 268,068 KB
実行使用メモリ 63,380 KB
最終ジャッジ日時 2023-08-22 07:01:42
合計ジャッジ時間 86,692 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 927 ms
62,648 KB
testcase_01 AC 929 ms
62,020 KB
testcase_02 AC 926 ms
62,280 KB
testcase_03 AC 956 ms
62,028 KB
testcase_04 AC 957 ms
62,392 KB
testcase_05 AC 977 ms
62,568 KB
testcase_06 AC 978 ms
62,332 KB
testcase_07 AC 977 ms
62,280 KB
testcase_08 AC 975 ms
62,404 KB
testcase_09 AC 976 ms
62,856 KB
testcase_10 AC 978 ms
62,264 KB
testcase_11 AC 978 ms
62,260 KB
testcase_12 AC 976 ms
62,488 KB
testcase_13 AC 947 ms
62,484 KB
testcase_14 AC 947 ms
61,916 KB
testcase_15 AC 963 ms
62,260 KB
testcase_16 AC 960 ms
62,588 KB
testcase_17 AC 960 ms
62,472 KB
testcase_18 AC 959 ms
62,140 KB
testcase_19 AC 966 ms
62,364 KB
testcase_20 AC 949 ms
62,176 KB
testcase_21 AC 950 ms
62,500 KB
testcase_22 AC 965 ms
62,468 KB
testcase_23 AC 957 ms
62,300 KB
testcase_24 AC 988 ms
62,372 KB
testcase_25 AC 983 ms
62,044 KB
testcase_26 AC 950 ms
62,372 KB
testcase_27 AC 963 ms
62,256 KB
testcase_28 AC 953 ms
62,432 KB
testcase_29 AC 953 ms
62,300 KB
testcase_30 AC 945 ms
62,552 KB
testcase_31 AC 930 ms
61,796 KB
testcase_32 AC 930 ms
61,940 KB
testcase_33 AC 957 ms
62,432 KB
testcase_34 AC 963 ms
63,380 KB
testcase_35 AC 963 ms
62,032 KB
testcase_36 AC 959 ms
62,516 KB
testcase_37 AC 964 ms
62,300 KB
testcase_38 AC 972 ms
62,412 KB
testcase_39 AC 974 ms
62,392 KB
testcase_40 AC 974 ms
62,384 KB
testcase_41 AC 969 ms
62,436 KB
testcase_42 AC 961 ms
62,420 KB
testcase_43 AC 972 ms
62,328 KB
testcase_44 AC 969 ms
62,176 KB
testcase_45 AC 973 ms
62,420 KB
testcase_46 AC 977 ms
62,732 KB
testcase_47 AC 976 ms
62,048 KB
testcase_48 AC 960 ms
62,076 KB
testcase_49 AC 948 ms
62,068 KB
testcase_50 AC 955 ms
61,840 KB
testcase_51 AC 976 ms
62,396 KB
testcase_52 AC 965 ms
62,016 KB
testcase_53 AC 927 ms
61,884 KB
testcase_54 AC 936 ms
62,456 KB
testcase_55 AC 937 ms
62,204 KB
testcase_56 AC 937 ms
62,128 KB
testcase_57 AC 936 ms
61,952 KB
testcase_58 AC 934 ms
62,212 KB
testcase_59 AC 928 ms
62,448 KB
testcase_60 AC 930 ms
62,308 KB
testcase_61 AC 935 ms
63,180 KB
testcase_62 AC 935 ms
62,272 KB
testcase_63 AC 935 ms
62,276 KB
testcase_64 AC 934 ms
62,344 KB
testcase_65 AC 932 ms
62,532 KB
testcase_66 AC 930 ms
62,092 KB
testcase_67 AC 937 ms
62,200 KB
testcase_68 AC 937 ms
62,172 KB
testcase_69 AC 939 ms
61,960 KB
testcase_70 AC 941 ms
62,312 KB
testcase_71 AC 928 ms
62,252 KB
testcase_72 AC 931 ms
62,548 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import scala.annotation.tailrec
import scala.io.StdIn.*

@tailrec def gcd(a: Int, b: Int): Int =
  b match
    case 0 => a
    case _ => gcd(b, a % b)

@main def main =
  val Array(n, m) = readLine().split(' ').map(_.toInt)
  val box = readLine().split(' ').map(_.toInt)
  if m > 0 then
    val unit = box.reduce(gcd)
    val count = box.map(_ / unit).sum
    val ratio = m / count
    println(box.map(_ / unit * ratio).mkString(" "))
  else
    println(box.mkString(" "))
0