結果

問題 No.1738 What's in the box?
ユーザー yudedakoyudedako
提出日時 2022-01-25 13:25:40
言語 Scala(Beta)
(3.4.0)
結果
AC  
実行時間 980 ms / 2,000 ms
コード長 472 bytes
コンパイル時間 11,803 ms
コンパイル使用メモリ 266,892 KB
実行使用メモリ 65,292 KB
最終ジャッジ日時 2024-05-09 12:55:29
合計ジャッジ時間 80,044 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 893 ms
65,020 KB
testcase_01 AC 896 ms
64,784 KB
testcase_02 AC 881 ms
64,892 KB
testcase_03 AC 908 ms
65,116 KB
testcase_04 AC 913 ms
65,076 KB
testcase_05 AC 932 ms
65,068 KB
testcase_06 AC 940 ms
64,972 KB
testcase_07 AC 927 ms
65,220 KB
testcase_08 AC 936 ms
65,152 KB
testcase_09 AC 928 ms
65,156 KB
testcase_10 AC 935 ms
64,980 KB
testcase_11 AC 931 ms
65,032 KB
testcase_12 AC 932 ms
64,888 KB
testcase_13 AC 980 ms
64,856 KB
testcase_14 AC 897 ms
64,952 KB
testcase_15 AC 892 ms
64,976 KB
testcase_16 AC 890 ms
64,844 KB
testcase_17 AC 892 ms
65,020 KB
testcase_18 AC 893 ms
65,056 KB
testcase_19 AC 900 ms
64,836 KB
testcase_20 AC 898 ms
65,012 KB
testcase_21 AC 899 ms
65,136 KB
testcase_22 AC 898 ms
65,100 KB
testcase_23 AC 880 ms
65,024 KB
testcase_24 AC 884 ms
64,888 KB
testcase_25 AC 883 ms
65,248 KB
testcase_26 AC 879 ms
64,828 KB
testcase_27 AC 900 ms
65,012 KB
testcase_28 AC 893 ms
64,920 KB
testcase_29 AC 877 ms
65,028 KB
testcase_30 AC 859 ms
64,888 KB
testcase_31 AC 866 ms
64,976 KB
testcase_32 AC 866 ms
64,740 KB
testcase_33 AC 896 ms
65,044 KB
testcase_34 AC 899 ms
65,088 KB
testcase_35 AC 886 ms
65,132 KB
testcase_36 AC 885 ms
65,292 KB
testcase_37 AC 888 ms
65,156 KB
testcase_38 AC 916 ms
65,256 KB
testcase_39 AC 896 ms
65,016 KB
testcase_40 AC 905 ms
65,068 KB
testcase_41 AC 898 ms
65,044 KB
testcase_42 AC 916 ms
65,096 KB
testcase_43 AC 915 ms
65,112 KB
testcase_44 AC 892 ms
65,276 KB
testcase_45 AC 901 ms
64,996 KB
testcase_46 AC 895 ms
65,032 KB
testcase_47 AC 905 ms
65,084 KB
testcase_48 AC 891 ms
65,120 KB
testcase_49 AC 907 ms
65,144 KB
testcase_50 AC 897 ms
65,040 KB
testcase_51 AC 905 ms
65,100 KB
testcase_52 AC 896 ms
65,076 KB
testcase_53 AC 937 ms
64,812 KB
testcase_54 AC 870 ms
64,864 KB
testcase_55 AC 881 ms
64,932 KB
testcase_56 AC 875 ms
64,800 KB
testcase_57 AC 868 ms
65,060 KB
testcase_58 AC 861 ms
65,112 KB
testcase_59 AC 880 ms
65,044 KB
testcase_60 AC 872 ms
65,004 KB
testcase_61 AC 879 ms
64,944 KB
testcase_62 AC 893 ms
64,980 KB
testcase_63 AC 882 ms
64,996 KB
testcase_64 AC 894 ms
64,848 KB
testcase_65 AC 895 ms
65,068 KB
testcase_66 AC 890 ms
64,900 KB
testcase_67 AC 888 ms
64,920 KB
testcase_68 AC 874 ms
64,916 KB
testcase_69 AC 871 ms
64,900 KB
testcase_70 AC 877 ms
64,992 KB
testcase_71 AC 888 ms
64,904 KB
testcase_72 AC 896 ms
64,952 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