結果

問題 No.339 何人が回答したのか
ユーザー YamaKasaYamaKasa
提出日時 2018-09-16 17:42:37
言語 Java21
(openjdk 21)
結果
AC  
実行時間 137 ms / 1,000 ms
コード長 891 bytes
コンパイル時間 2,268 ms
コンパイル使用メモリ 79,324 KB
実行使用メモリ 56,432 KB
最終ジャッジ日時 2023-09-25 09:03:11
合計ジャッジ時間 13,233 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 137 ms
55,772 KB
testcase_01 AC 133 ms
55,692 KB
testcase_02 AC 128 ms
55,484 KB
testcase_03 AC 125 ms
55,728 KB
testcase_04 AC 126 ms
55,772 KB
testcase_05 AC 129 ms
56,324 KB
testcase_06 AC 129 ms
55,888 KB
testcase_07 AC 127 ms
56,432 KB
testcase_08 AC 125 ms
55,660 KB
testcase_09 AC 130 ms
55,688 KB
testcase_10 AC 129 ms
55,696 KB
testcase_11 AC 130 ms
55,436 KB
testcase_12 AC 131 ms
55,480 KB
testcase_13 AC 126 ms
55,932 KB
testcase_14 AC 124 ms
55,440 KB
testcase_15 AC 131 ms
55,732 KB
testcase_16 AC 129 ms
55,872 KB
testcase_17 AC 129 ms
56,240 KB
testcase_18 AC 129 ms
55,896 KB
testcase_19 AC 129 ms
55,896 KB
testcase_20 AC 124 ms
53,988 KB
testcase_21 AC 125 ms
55,440 KB
testcase_22 AC 129 ms
55,896 KB
testcase_23 AC 126 ms
55,816 KB
testcase_24 AC 129 ms
55,928 KB
testcase_25 AC 125 ms
55,632 KB
testcase_26 AC 128 ms
53,848 KB
testcase_27 AC 128 ms
55,864 KB
testcase_28 AC 129 ms
55,876 KB
testcase_29 AC 127 ms
55,720 KB
testcase_30 AC 129 ms
55,668 KB
testcase_31 AC 128 ms
55,748 KB
testcase_32 AC 129 ms
55,860 KB
testcase_33 AC 127 ms
56,004 KB
testcase_34 AC 126 ms
55,712 KB
testcase_35 AC 129 ms
55,924 KB
testcase_36 AC 129 ms
55,860 KB
testcase_37 AC 131 ms
55,664 KB
testcase_38 AC 129 ms
54,052 KB
testcase_39 AC 130 ms
55,768 KB
testcase_40 AC 128 ms
56,268 KB
testcase_41 AC 127 ms
55,736 KB
testcase_42 AC 125 ms
55,616 KB
testcase_43 AC 127 ms
55,656 KB
testcase_44 AC 129 ms
55,772 KB
testcase_45 AC 129 ms
55,436 KB
testcase_46 AC 127 ms
56,044 KB
testcase_47 AC 126 ms
56,052 KB
testcase_48 AC 125 ms
55,752 KB
testcase_49 AC 126 ms
56,028 KB
testcase_50 AC 124 ms
55,784 KB
testcase_51 AC 125 ms
56,020 KB
testcase_52 AC 126 ms
55,852 KB
testcase_53 AC 126 ms
55,776 KB
testcase_54 AC 125 ms
55,652 KB
testcase_55 AC 124 ms
55,648 KB
testcase_56 AC 126 ms
55,700 KB
testcase_57 AC 123 ms
56,128 KB
testcase_58 AC 124 ms
56,036 KB
testcase_59 AC 129 ms
55,976 KB
testcase_60 AC 125 ms
55,880 KB
testcase_61 AC 122 ms
55,864 KB
testcase_62 AC 123 ms
55,688 KB
testcase_63 AC 123 ms
55,872 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[]A = new int[n];
		int min = Integer.MAX_VALUE;
		for(int i = 0; i < n; i++) {
			int t = scan.nextInt();
			A[i] = t;
			if(min > t) {
				min = t;
			}
		}
		scan.close();
		List<Integer> list = new ArrayList<Integer>();
		for(int i = 2; i <= min; i++) {
			if(min % i == 0) {
				list.add(i);
			}
		}
		for(int i = list.size() - 1; i >= 0; i--) {
			int k = list.get(i);
			boolean flag = true;
			for(int j = 0; j < n; j++) {
				if(A[j] % k != 0) {
					flag = false;
					break;
				}
			}
			if(flag) {
				for(int j = 0; j < n; j++) {
					A[j] = A[j] / k;
				}
			}
		}
		int cnt = 0;
		for(int i = 0; i < n; i++) {
			cnt += A[i];
		}
		System.out.println(cnt);
	}
}
0