結果

問題 No.1738 What's in the box?
ユーザー CuriousFairy315CuriousFairy315
提出日時 2021-11-12 22:19:32
言語 Java21
(openjdk 21)
結果
AC  
実行時間 250 ms / 2,000 ms
コード長 705 bytes
コンパイル時間 2,132 ms
コンパイル使用メモリ 75,916 KB
実行使用メモリ 57,632 KB
最終ジャッジ日時 2023-08-17 02:05:01
合計ジャッジ時間 17,734 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 137 ms
55,952 KB
testcase_01 AC 135 ms
56,344 KB
testcase_02 AC 133 ms
55,852 KB
testcase_03 AC 244 ms
56,924 KB
testcase_04 AC 241 ms
56,800 KB
testcase_05 AC 242 ms
56,980 KB
testcase_06 AC 242 ms
57,016 KB
testcase_07 AC 241 ms
57,016 KB
testcase_08 AC 239 ms
57,164 KB
testcase_09 AC 243 ms
57,632 KB
testcase_10 AC 233 ms
57,392 KB
testcase_11 AC 244 ms
57,340 KB
testcase_12 AC 238 ms
57,212 KB
testcase_13 AC 134 ms
55,960 KB
testcase_14 AC 139 ms
56,160 KB
testcase_15 AC 137 ms
56,152 KB
testcase_16 AC 139 ms
55,752 KB
testcase_17 AC 141 ms
55,856 KB
testcase_18 AC 139 ms
55,484 KB
testcase_19 AC 140 ms
56,040 KB
testcase_20 AC 140 ms
55,508 KB
testcase_21 AC 160 ms
56,288 KB
testcase_22 AC 144 ms
56,132 KB
testcase_23 AC 138 ms
56,060 KB
testcase_24 AC 177 ms
56,336 KB
testcase_25 AC 172 ms
56,208 KB
testcase_26 AC 136 ms
55,840 KB
testcase_27 AC 138 ms
55,976 KB
testcase_28 AC 139 ms
55,668 KB
testcase_29 AC 138 ms
56,076 KB
testcase_30 AC 135 ms
55,500 KB
testcase_31 AC 155 ms
55,916 KB
testcase_32 AC 160 ms
56,416 KB
testcase_33 AC 232 ms
56,768 KB
testcase_34 AC 241 ms
57,480 KB
testcase_35 AC 225 ms
57,192 KB
testcase_36 AC 238 ms
57,620 KB
testcase_37 AC 225 ms
56,992 KB
testcase_38 AC 243 ms
57,248 KB
testcase_39 AC 236 ms
57,492 KB
testcase_40 AC 245 ms
57,408 KB
testcase_41 AC 241 ms
57,136 KB
testcase_42 AC 240 ms
57,152 KB
testcase_43 AC 242 ms
57,000 KB
testcase_44 AC 234 ms
56,784 KB
testcase_45 AC 229 ms
57,412 KB
testcase_46 AC 244 ms
57,484 KB
testcase_47 AC 238 ms
55,588 KB
testcase_48 AC 249 ms
57,524 KB
testcase_49 AC 250 ms
57,192 KB
testcase_50 AC 238 ms
57,444 KB
testcase_51 AC 241 ms
56,780 KB
testcase_52 AC 248 ms
57,352 KB
testcase_53 AC 136 ms
55,788 KB
testcase_54 AC 134 ms
55,836 KB
testcase_55 AC 134 ms
56,052 KB
testcase_56 AC 152 ms
55,840 KB
testcase_57 AC 139 ms
55,788 KB
testcase_58 AC 135 ms
56,352 KB
testcase_59 AC 132 ms
55,876 KB
testcase_60 AC 134 ms
55,732 KB
testcase_61 AC 135 ms
56,096 KB
testcase_62 AC 120 ms
56,048 KB
testcase_63 AC 134 ms
56,036 KB
testcase_64 AC 135 ms
56,192 KB
testcase_65 AC 135 ms
55,484 KB
testcase_66 AC 134 ms
56,336 KB
testcase_67 AC 137 ms
55,404 KB
testcase_68 AC 135 ms
56,412 KB
testcase_69 AC 140 ms
56,300 KB
testcase_70 AC 137 ms
55,964 KB
testcase_71 AC 118 ms
56,024 KB
testcase_72 AC 133 ms
55,848 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int N = sc.nextInt(), M = sc.nextInt();
			int[] W = new int[N];
			for (int i = 0;i < N;++ i) W[i] = sc.nextInt();
			int[] A = new int[N];
			if (M != 0) {
				int gcd = 0;
				for (int i : W) gcd = gcd(gcd, i);
				int sum = 0;
				for (int i = 0;i < N;++ i) sum += W[i] /= gcd;
				for (int i = 0;i < N;++ i) A[i] = M / sum * W[i];
			}
			System.out.print(A[0]);
			for (int i = 1;i < N;++ i) System.out.print(" " + A[i]);
			System.out.println();
		}
	}

	static int gcd(int a, int b) {
		while(b != 0) if((a %= b) != 0) b %= a; else return b;
		return a;
	}
}
0