結果

問題 No.276 連続する整数の和(1)
ユーザー uafr_csuafr_cs
提出日時 2015-09-04 22:41:26
言語 Java21
(openjdk 21)
結果
AC  
実行時間 123 ms / 1,000 ms
コード長 406 bytes
コンパイル時間 4,363 ms
コンパイル使用メモリ 75,748 KB
実行使用メモリ 56,176 KB
最終ジャッジ日時 2023-09-26 05:51:13
合計ジャッジ時間 4,200 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 123 ms
55,792 KB
testcase_01 AC 118 ms
56,060 KB
testcase_02 AC 123 ms
55,728 KB
testcase_03 AC 119 ms
56,036 KB
testcase_04 AC 118 ms
56,048 KB
testcase_05 AC 118 ms
55,736 KB
testcase_06 AC 116 ms
56,048 KB
testcase_07 AC 117 ms
56,176 KB
testcase_08 AC 122 ms
55,368 KB
testcase_09 AC 118 ms
55,756 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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();
		System.out.println(gcd(N, (N * (N - 1) / 2)));
		
	}

}
0