結果
問題 | No.278 連続する整数の和(2) |
ユーザー | uafr_cs |
提出日時 | 2015-09-04 23:06:30 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 139 ms / 2,000 ms |
コード長 | 877 bytes |
コンパイル時間 | 2,289 ms |
コンパイル使用メモリ | 72,876 KB |
実行使用メモリ | 56,416 KB |
最終ジャッジ日時 | 2023-08-24 22:36:30 |
合計ジャッジ時間 | 5,359 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 121 ms
55,856 KB |
testcase_01 | AC | 121 ms
56,276 KB |
testcase_02 | AC | 139 ms
55,624 KB |
testcase_03 | AC | 121 ms
56,020 KB |
testcase_04 | AC | 120 ms
55,920 KB |
testcase_05 | AC | 119 ms
55,868 KB |
testcase_06 | AC | 120 ms
55,908 KB |
testcase_07 | AC | 121 ms
56,056 KB |
testcase_08 | AC | 136 ms
55,852 KB |
testcase_09 | AC | 137 ms
56,212 KB |
testcase_10 | AC | 138 ms
55,808 KB |
testcase_11 | AC | 137 ms
55,760 KB |
testcase_12 | AC | 119 ms
55,852 KB |
testcase_13 | AC | 135 ms
56,416 KB |
testcase_14 | AC | 131 ms
56,000 KB |
testcase_15 | AC | 132 ms
55,824 KB |
testcase_16 | AC | 129 ms
56,176 KB |
testcase_17 | AC | 133 ms
55,684 KB |
ソースコード
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 / 2; //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); } }