結果

問題 No.278 連続する整数の和(2)
ユーザー GrenacheGrenache
提出日時 2015-09-04 23:09:43
言語 Java21
(openjdk 21)
結果
AC  
実行時間 160 ms / 2,000 ms
コード長 972 bytes
コンパイル時間 3,428 ms
コンパイル使用メモリ 74,880 KB
実行使用メモリ 56,428 KB
最終ジャッジ日時 2023-08-24 22:38:10
合計ジャッジ時間 6,903 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
55,884 KB
testcase_01 AC 124 ms
53,928 KB
testcase_02 AC 143 ms
56,016 KB
testcase_03 AC 123 ms
55,916 KB
testcase_04 AC 124 ms
55,636 KB
testcase_05 AC 127 ms
55,884 KB
testcase_06 AC 126 ms
55,772 KB
testcase_07 AC 125 ms
56,112 KB
testcase_08 AC 142 ms
55,936 KB
testcase_09 AC 142 ms
55,724 KB
testcase_10 AC 144 ms
55,900 KB
testcase_11 AC 160 ms
56,404 KB
testcase_12 AC 123 ms
56,004 KB
testcase_13 AC 155 ms
56,428 KB
testcase_14 AC 138 ms
55,756 KB
testcase_15 AC 139 ms
55,740 KB
testcase_16 AC 137 ms
56,016 KB
testcase_17 AC 143 ms
55,920 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;


public class Main_yukicoder278 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        long n = sc.nextLong();

        if (n == 1) {
        } else if (n % 2 == 1) {
        } else {
        	n = n / 2;
        }

		Map<Long, Integer> hm = new HashMap<Long, Integer>();
		long nn = n;
		for (long j = 2; j * j <= nn; j++) {
			while (n % j == 0) {
				if (hm.containsKey(j)) {
					hm.put(j, hm.get(j) + 1);
				} else {
					hm.put(j, 1);
				}
				n /= j;
			}
		}
		if (n != 1) {
			if (hm.containsKey(n)) {
				hm.put(n, hm.get(n) + 1);
			} else {
				hm.put(n, 1);
			}
		}

		long ret = 1;
		for (Map.Entry<Long, Integer> e : hm.entrySet()) {
			long tmp = 1;
			long tmp2 = 1;
			for (int i = 0; i < e.getValue(); i++) {
				tmp *= e.getKey();
				tmp2 += tmp;
			}
			ret *= tmp2;
		}
		
		System.out.println(ret);
		
		sc.close();
    }
}
0