結果

問題 No.1738 What's in the box?
ユーザー tentententen
提出日時 2023-02-22 14:28:15
言語 Java21
(openjdk 21)
結果
RE  
実行時間 -
コード長 2,234 bytes
コンパイル時間 2,888 ms
コンパイル使用メモリ 80,864 KB
実行使用メモリ 51,624 KB
最終ジャッジ日時 2023-09-29 22:33:40
合計ジャッジ時間 7,943 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
49,380 KB
testcase_01 AC 42 ms
49,360 KB
testcase_02 AC 42 ms
49,268 KB
testcase_03 AC 52 ms
49,756 KB
testcase_04 AC 53 ms
49,552 KB
testcase_05 AC 51 ms
49,628 KB
testcase_06 AC 53 ms
49,308 KB
testcase_07 AC 56 ms
50,680 KB
testcase_08 AC 51 ms
49,308 KB
testcase_09 AC 57 ms
50,664 KB
testcase_10 AC 53 ms
49,476 KB
testcase_11 AC 50 ms
50,496 KB
testcase_12 AC 56 ms
50,676 KB
testcase_13 AC 42 ms
49,268 KB
testcase_14 AC 44 ms
49,352 KB
testcase_15 AC 42 ms
49,780 KB
testcase_16 AC 43 ms
49,348 KB
testcase_17 AC 42 ms
49,412 KB
testcase_18 AC 42 ms
49,468 KB
testcase_19 AC 43 ms
49,428 KB
testcase_20 AC 43 ms
49,384 KB
testcase_21 AC 44 ms
49,344 KB
testcase_22 AC 43 ms
49,624 KB
testcase_23 AC 42 ms
49,364 KB
testcase_24 AC 46 ms
49,280 KB
testcase_25 AC 44 ms
49,324 KB
testcase_26 AC 42 ms
49,376 KB
testcase_27 AC 43 ms
49,496 KB
testcase_28 AC 43 ms
49,880 KB
testcase_29 AC 43 ms
49,408 KB
testcase_30 AC 43 ms
49,380 KB
testcase_31 RE -
testcase_32 RE -
testcase_33 AC 48 ms
49,396 KB
testcase_34 AC 50 ms
49,764 KB
testcase_35 AC 49 ms
49,508 KB
testcase_36 AC 51 ms
49,608 KB
testcase_37 AC 49 ms
49,548 KB
testcase_38 AC 53 ms
49,396 KB
testcase_39 AC 50 ms
49,416 KB
testcase_40 AC 54 ms
50,568 KB
testcase_41 AC 55 ms
49,912 KB
testcase_42 AC 50 ms
49,308 KB
testcase_43 AC 58 ms
50,488 KB
testcase_44 AC 54 ms
50,436 KB
testcase_45 AC 52 ms
49,580 KB
testcase_46 AC 57 ms
50,660 KB
testcase_47 AC 52 ms
49,536 KB
testcase_48 AC 55 ms
49,908 KB
testcase_49 AC 51 ms
49,464 KB
testcase_50 AC 51 ms
49,900 KB
testcase_51 AC 55 ms
49,436 KB
testcase_52 AC 54 ms
50,752 KB
testcase_53 AC 42 ms
49,356 KB
testcase_54 AC 42 ms
49,464 KB
testcase_55 AC 42 ms
49,236 KB
testcase_56 AC 43 ms
49,512 KB
testcase_57 AC 42 ms
49,264 KB
testcase_58 AC 42 ms
49,736 KB
testcase_59 AC 42 ms
49,544 KB
testcase_60 AC 42 ms
49,308 KB
testcase_61 AC 42 ms
49,456 KB
testcase_62 AC 42 ms
49,432 KB
testcase_63 AC 45 ms
49,880 KB
testcase_64 AC 45 ms
49,504 KB
testcase_65 AC 42 ms
49,304 KB
testcase_66 AC 42 ms
49,444 KB
testcase_67 AC 41 ms
49,468 KB
testcase_68 AC 42 ms
49,472 KB
testcase_69 AC 41 ms
49,356 KB
testcase_70 AC 42 ms
49,236 KB
testcase_71 AC 41 ms
49,540 KB
testcase_72 AC 42 ms
49,328 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;
import java.util.stream.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        int n = sc.nextInt();
        int m = sc.nextInt();
        long[] values = new long[n];
        long total = 0;
        for (int i = 0; i < n; i++) {
            values[i] = sc.nextInt();
            total += values[i];
        }
        long gcd = getGCD(m, total);
        m /= gcd;
        total /= gcd;
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < n; i++) {
            if (i > 0) {
                sb.append(" ");
            }
            if (total == 0) {
                sb.append(0);
            } else {
                sb.append(values[i] * m / total);
            }
        }
        System.out.println(sb);
    }
    
    static long getGCD(long x, long y) {
        if (y == 0) {
            return x;
        } else {
            return getGCD(y, x % y);
        }
    }
}
class Utilities {
    static String arrayToLineString(Object[] arr) {
        return Arrays.stream(arr).map(x -> x.toString()).collect(Collectors.joining("\n"));
    }
    
    static String arrayToLineString(int[] arr) {
        return String.join("\n", Arrays.stream(arr).mapToObj(String::valueOf).toArray(String[]::new));
    }
}
class Scanner {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    StringBuilder sb = new StringBuilder();
    
    public Scanner() throws Exception {
        
    }
    
    public int nextInt() throws Exception {
        return Integer.parseInt(next());
    }
    
    public long nextLong() throws Exception {
        return Long.parseLong(next());
    }
    
    public double nextDouble() throws Exception {
        return Double.parseDouble(next());
    }
    
    public int[] nextIntArray() throws Exception {
        return Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
    }
    
    public String next() throws Exception {
        while (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
    
}
0