結果

問題 No.278 連続する整数の和(2)
ユーザー tentententen
提出日時 2021-11-11 08:22:32
言語 Java19
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,302 bytes
コンパイル時間 2,481 ms
コンパイル使用メモリ 73,788 KB
実行使用メモリ 51,148 KB
最終ジャッジ日時 2023-08-14 11:18:50
合計ジャッジ時間 4,736 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
49,340 KB
testcase_01 AC 43 ms
49,384 KB
testcase_02 AC 61 ms
50,988 KB
testcase_03 AC 41 ms
49,272 KB
testcase_04 AC 41 ms
49,300 KB
testcase_05 AC 43 ms
49,412 KB
testcase_06 AC 44 ms
49,492 KB
testcase_07 AC 43 ms
49,472 KB
testcase_08 WA -
testcase_09 AC 62 ms
51,148 KB
testcase_10 AC 65 ms
50,980 KB
testcase_11 AC 65 ms
50,860 KB
testcase_12 AC 42 ms
49,392 KB
testcase_13 AC 60 ms
50,868 KB
testcase_14 AC 57 ms
48,820 KB
testcase_15 AC 58 ms
50,672 KB
testcase_16 AC 55 ms
50,940 KB
testcase_17 AC 61 ms
50,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        long n = sc.nextLong();
        if (n % 2 == 0) {
            n /= 2;
        }
        long ans = 0;
        for (int i = 1; i <= Math.sqrt(n); i++) {
            if (n % i == 0) {
                ans += i;
                if (i * i < n) {
                    ans += n / i;
                }
            }
        }
        System.out.println(ans);
    }
    
}
class Scanner {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    
    public Scanner() throws Exception {
        
    }
    
    public int nextInt() throws Exception {
        return Integer.parseInt(next());
    }
    
    public long nextLong() throws Exception {
        return Long.parseLong(next());
    }
    
    public double nextDouble() throws Exception {
        return Double.parseDouble(next());
    }
    
    public String nextLine() throws Exception {
        return br.readLine();
    }
    
    public String next() throws Exception {
        if (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
}
0