結果

問題 No.278 連続する整数の和(2)
ユーザー Grenache
提出日時 2015-09-05 09:24:19
言語 Java
(openjdk 23)
結果
AC  
実行時間 137 ms / 2,000 ms
コード長 644 bytes
コンパイル時間 2,909 ms
コンパイル使用メモリ 74,448 KB
実行使用メモリ 41,768 KB
最終ジャッジ日時 2024-12-23 09:04:16
合計ジャッジ時間 5,865 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;


public class Main_yukicoder278_1 {

    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;
        }

        if (n != 1) {
        	long ret = 0;
        	for (long j = 1; j * j <= n; j++) {
        		if (n % j == 0) {
        			ret += j;
        			if (j != n / j) {
        				ret += n / j;
        			}
        		}
        	}
		
        	System.out.println(ret);
        } else {
        	System.out.println("1");
        }
		
		sc.close();
    }
}
0