結果

問題 No.276 連続する整数の和(1)
ユーザー gu_21816943
提出日時 2017-06-27 01:49:26
言語 Java
(openjdk 23)
結果
WA  
実行時間 -
コード長 531 bytes
コンパイル時間 2,267 ms
コンパイル使用メモリ 74,364 KB
実行使用メモリ 51,116 KB
最終ジャッジ日時 2024-10-04 10:00:46
合計ジャッジ時間 5,536 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 3 WA * 7
権限があれば一括ダウンロードができます

ソースコード

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