結果

問題 No.136 Yet Another GCD Problem
ユーザー kou6839
提出日時 2015-02-23 16:08:08
言語 Java
(openjdk 23)
結果
AC  
実行時間 137 ms / 5,000 ms
コード長 393 bytes
コンパイル時間 2,064 ms
コンパイル使用メモリ 74,684 KB
実行使用メモリ 54,440 KB
最終ジャッジ日時 2024-06-23 21:56:45
合計ジャッジ時間 8,734 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 39
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.math.*;
import java.util.*;

class Main {
	static int gcd(int dai,int syou){
		if(syou==0) return dai;
		else return gcd(syou, dai%syou);
		
	}
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y=sc.nextInt();
		int ans=1;
		for(int i=1;i<=x/2;i++){
			ans=Math.max(ans, gcd(x-i, i));
		}
		System.out.println(ans);
	}
}
0