結果
問題 | No.1738 What's in the box? |
ユーザー | tenten |
提出日時 | 2023-04-19 08:47:17 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 89 ms / 2,000 ms |
コード長 | 2,190 bytes |
コンパイル時間 | 2,863 ms |
コンパイル使用メモリ | 87,048 KB |
実行使用メモリ | 53,296 KB |
最終ジャッジ日時 | 2024-10-14 08:30:24 |
合計ジャッジ時間 | 10,444 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 70 ms
51,052 KB |
testcase_01 | AC | 71 ms
51,212 KB |
testcase_02 | AC | 70 ms
51,304 KB |
testcase_03 | AC | 83 ms
51,504 KB |
testcase_04 | AC | 87 ms
51,204 KB |
testcase_05 | AC | 81 ms
51,256 KB |
testcase_06 | AC | 83 ms
51,316 KB |
testcase_07 | AC | 86 ms
51,644 KB |
testcase_08 | AC | 85 ms
51,512 KB |
testcase_09 | AC | 89 ms
51,428 KB |
testcase_10 | AC | 82 ms
51,320 KB |
testcase_11 | AC | 81 ms
51,252 KB |
testcase_12 | AC | 83 ms
51,368 KB |
testcase_13 | AC | 70 ms
51,052 KB |
testcase_14 | AC | 72 ms
51,256 KB |
testcase_15 | AC | 71 ms
50,956 KB |
testcase_16 | AC | 70 ms
51,288 KB |
testcase_17 | AC | 70 ms
51,036 KB |
testcase_18 | AC | 68 ms
51,176 KB |
testcase_19 | AC | 70 ms
51,200 KB |
testcase_20 | AC | 69 ms
51,132 KB |
testcase_21 | AC | 74 ms
51,192 KB |
testcase_22 | AC | 71 ms
50,904 KB |
testcase_23 | AC | 69 ms
51,128 KB |
testcase_24 | AC | 77 ms
51,564 KB |
testcase_25 | AC | 74 ms
51,276 KB |
testcase_26 | AC | 72 ms
51,184 KB |
testcase_27 | AC | 72 ms
53,296 KB |
testcase_28 | AC | 68 ms
51,136 KB |
testcase_29 | AC | 70 ms
51,160 KB |
testcase_30 | AC | 71 ms
51,148 KB |
testcase_31 | AC | 72 ms
51,184 KB |
testcase_32 | AC | 72 ms
50,828 KB |
testcase_33 | AC | 79 ms
51,364 KB |
testcase_34 | AC | 81 ms
50,880 KB |
testcase_35 | AC | 84 ms
51,308 KB |
testcase_36 | AC | 79 ms
51,364 KB |
testcase_37 | AC | 79 ms
51,152 KB |
testcase_38 | AC | 83 ms
51,056 KB |
testcase_39 | AC | 81 ms
51,348 KB |
testcase_40 | AC | 87 ms
51,776 KB |
testcase_41 | AC | 84 ms
51,440 KB |
testcase_42 | AC | 81 ms
51,340 KB |
testcase_43 | AC | 89 ms
51,900 KB |
testcase_44 | AC | 85 ms
51,552 KB |
testcase_45 | AC | 85 ms
51,436 KB |
testcase_46 | AC | 86 ms
51,392 KB |
testcase_47 | AC | 83 ms
51,408 KB |
testcase_48 | AC | 86 ms
51,444 KB |
testcase_49 | AC | 84 ms
51,528 KB |
testcase_50 | AC | 85 ms
51,324 KB |
testcase_51 | AC | 87 ms
51,528 KB |
testcase_52 | AC | 88 ms
51,720 KB |
testcase_53 | AC | 69 ms
51,176 KB |
testcase_54 | AC | 70 ms
51,184 KB |
testcase_55 | AC | 70 ms
50,980 KB |
testcase_56 | AC | 73 ms
51,196 KB |
testcase_57 | AC | 70 ms
50,864 KB |
testcase_58 | AC | 70 ms
51,356 KB |
testcase_59 | AC | 70 ms
51,300 KB |
testcase_60 | AC | 70 ms
51,064 KB |
testcase_61 | AC | 70 ms
51,208 KB |
testcase_62 | AC | 70 ms
51,188 KB |
testcase_63 | AC | 69 ms
50,916 KB |
testcase_64 | AC | 70 ms
51,144 KB |
testcase_65 | AC | 69 ms
50,944 KB |
testcase_66 | AC | 70 ms
51,056 KB |
testcase_67 | AC | 70 ms
51,304 KB |
testcase_68 | AC | 70 ms
51,376 KB |
testcase_69 | AC | 71 ms
51,236 KB |
testcase_70 | AC | 70 ms
51,072 KB |
testcase_71 | AC | 71 ms
50,900 KB |
testcase_72 | AC | 70 ms
51,420 KB |
ソースコード
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(); long count = 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(count, total); if (gcd > 0) { count /= gcd; total /= gcd; for (int i = 0; i < n; i++) { values[i] /= total; values[i] *= count; } } System.out.println(String.join(" ", Arrays.stream(values).mapToObj(String::valueOf).toArray(String[]::new))); } 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(); } }