結果

問題 No.278 連続する整数の和(2)
ユーザー uafr_csuafr_cs
提出日時 2015-09-04 23:05:51
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 877 bytes
コンパイル時間 2,380 ms
コンパイル使用メモリ 72,708 KB
実行使用メモリ 56,136 KB
最終ジャッジ日時 2023-09-26 06:19:40
合計ジャッジ時間 5,932 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 131 ms
55,676 KB
testcase_01 AC 128 ms
55,760 KB
testcase_02 AC 145 ms
55,924 KB
testcase_03 AC 125 ms
55,676 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 129 ms
55,712 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 143 ms
55,768 KB
testcase_10 AC 145 ms
55,860 KB
testcase_11 WA -
testcase_12 AC 127 ms
55,944 KB
testcase_13 WA -
testcase_14 AC 139 ms
55,908 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 146 ms
55,820 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.math.BigInteger;
import java.util.Arrays;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Scanner;
import java.util.Set;

public class Main {

	public static long gcd(long a, long b){
		return b == 0 ? a : gcd(b, a % b);
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		final long N = sc.nextLong();
		
		final long max = N % 2 != 0 ? N : N - 1;
		//System.out.println(max);
		final long sqrt = (long)(Math.floor(Math.sqrt(max)));
		
		long answer = 0;
		for(long div_fst = 1; div_fst <= sqrt; div_fst++){
			if(max % div_fst != 0) { continue; }
			
			final long div_snd = max / div_fst;
			if(div_fst > div_snd){ break; }
			//System.out.println(div_fst + " " + div_snd);
			
			answer += div_fst;
			if(div_fst < div_snd){
				answer += div_snd;
			}
		}
		
		System.out.println(answer);
		
	}

}
0