結果

問題 No.276 連続する整数の和(1)
ユーザー gu_21816943gu_21816943
提出日時 2017-06-27 01:51:39
言語 Java21
(openjdk 21)
結果
AC  
実行時間 972 ms / 1,000 ms
コード長 542 bytes
コンパイル時間 1,865 ms
コンパイル使用メモリ 74,672 KB
実行使用メモリ 51,056 KB
最終ジャッジ日時 2024-04-15 02:03:43
合計ジャッジ時間 5,931 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 52 ms
49,940 KB
testcase_01 AC 52 ms
50,240 KB
testcase_02 AC 51 ms
49,976 KB
testcase_03 AC 178 ms
51,048 KB
testcase_04 AC 177 ms
51,036 KB
testcase_05 AC 966 ms
50,952 KB
testcase_06 AC 972 ms
50,988 KB
testcase_07 AC 874 ms
51,004 KB
testcase_08 AC 73 ms
51,056 KB
testcase_09 AC 54 ms
50,036 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int num=Integer.parseInt(br.readLine());
		br.close();

		long sum1=0,sum2=0;
		int i;
		for(i=1;i<=num;i++){
			sum1+=i;
			sum2+=i+1;
		}
		System.out.println(euclid(sum2,sum1));

	}

	public static long euclid(long a,long b){
		if(b==0){
			return a;
		}else{
			return euclid(b,a%b);
		}
	}
}
0