結果

問題 No.278 連続する整数の和(2)
ユーザー nanophoto12nanophoto12
提出日時 2015-09-13 17:30:05
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 752 bytes
コンパイル時間 2,364 ms
コンパイル使用メモリ 72,172 KB
実行使用メモリ 58,672 KB
最終ジャッジ日時 2023-09-26 11:46:31
合計ジャッジ時間 5,584 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 121 ms
55,660 KB
testcase_01 AC 124 ms
55,812 KB
testcase_02 AC 158 ms
58,048 KB
testcase_03 AC 125 ms
55,844 KB
testcase_04 AC 122 ms
55,988 KB
testcase_05 AC 126 ms
56,364 KB
testcase_06 AC 129 ms
55,616 KB
testcase_07 AC 128 ms
55,796 KB
testcase_08 WA -
testcase_09 AC 158 ms
58,200 KB
testcase_10 AC 159 ms
58,596 KB
testcase_11 AC 165 ms
58,384 KB
testcase_12 AC 122 ms
55,580 KB
testcase_13 AC 159 ms
58,036 KB
testcase_14 AC 150 ms
58,104 KB
testcase_15 AC 150 ms
58,172 KB
testcase_16 AC 149 ms
58,584 KB
testcase_17 AC 157 ms
58,228 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package com.company;

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        Long value = scanner.nextLong();
        if(value % 2 == 0)
        {
            value /=2;
        }
        double root = Math.sqrt((double) value);
        Long sum = 0L;
        for(Long i = 1L; i <= root;i++)
        {
            if(value % i == 0)
            {
                Long other = value / i;
                if(i == other)
                {
                    sum += i;
                }
                else
                {
                    sum += i + other;
                }
            }
        }

        System.out.println(sum.toString());
    }
}
0