結果

問題 No.276 連続する整数の和(1)
ユーザー tentententen
提出日時 2020-10-05 09:36:48
言語 Java17
(openjdk 17.0.1)
結果
AC  
実行時間 101 ms / 1,000 ms
コード長 414 bytes
コンパイル時間 2,226 ms
使用メモリ 37,652 KB
最終ジャッジ日時 2023-02-18 06:13:38
合計ジャッジ時間 4,390 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 101 ms
37,568 KB
testcase_01 AC 94 ms
37,480 KB
testcase_02 AC 94 ms
37,652 KB
testcase_03 AC 95 ms
37,616 KB
testcase_04 AC 94 ms
37,260 KB
testcase_05 AC 93 ms
37,484 KB
testcase_06 AC 97 ms
37,476 KB
testcase_07 AC 95 ms
37,312 KB
testcase_08 AC 101 ms
37,640 KB
testcase_09 AC 94 ms
37,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long x = getGCD(n, (long)n * (n + 1) / 2);
        System.out.println(x);
    }
    
    static long getGCD(long x, long y) {
        if (x % y == 0) {
            return y;
        } else {
            return getGCD(y, x % y);
        }
    }
}
0