結果

問題 No.276 連続する整数の和(1)
ユーザー gu_21816943gu_21816943
提出日時 2017-06-27 01:49:26
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 531 bytes
コンパイル時間 1,953 ms
コンパイル使用メモリ 74,440 KB
実行使用メモリ 53,128 KB
最終ジャッジ日時 2024-04-15 02:03:35
合計ジャッジ時間 5,466 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 53 ms
50,032 KB
testcase_01 AC 53 ms
50,280 KB
testcase_02 AC 53 ms
50,088 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
権限があれば一括ダウンロードができます

ソースコード

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();

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

	}

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