結果

問題 No.136 Yet Another GCD Problem
ユーザー kou6839kou6839
提出日時 2015-02-23 16:08:08
言語 Java21
(openjdk 21)
結果
AC  
実行時間 137 ms / 5,000 ms
コード長 393 bytes
コンパイル時間 2,190 ms
コンパイル使用メモリ 72,184 KB
実行使用メモリ 56,120 KB
最終ジャッジ日時 2023-09-06 03:04:44
合計ジャッジ時間 9,642 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 127 ms
55,732 KB
testcase_01 AC 127 ms
55,732 KB
testcase_02 AC 127 ms
55,852 KB
testcase_03 AC 132 ms
55,908 KB
testcase_04 AC 134 ms
55,804 KB
testcase_05 AC 132 ms
55,540 KB
testcase_06 AC 130 ms
55,828 KB
testcase_07 AC 130 ms
55,892 KB
testcase_08 AC 133 ms
56,112 KB
testcase_09 AC 129 ms
55,536 KB
testcase_10 AC 130 ms
53,732 KB
testcase_11 AC 133 ms
55,948 KB
testcase_12 AC 129 ms
55,484 KB
testcase_13 AC 130 ms
55,916 KB
testcase_14 AC 134 ms
56,120 KB
testcase_15 AC 136 ms
55,852 KB
testcase_16 AC 136 ms
55,860 KB
testcase_17 AC 134 ms
55,844 KB
testcase_18 AC 129 ms
55,844 KB
testcase_19 AC 136 ms
56,100 KB
testcase_20 AC 134 ms
55,768 KB
testcase_21 AC 130 ms
55,740 KB
testcase_22 AC 128 ms
56,004 KB
testcase_23 AC 129 ms
55,748 KB
testcase_24 AC 129 ms
56,052 KB
testcase_25 AC 131 ms
55,696 KB
testcase_26 AC 133 ms
55,568 KB
testcase_27 AC 137 ms
55,576 KB
testcase_28 AC 134 ms
55,812 KB
testcase_29 AC 129 ms
55,904 KB
testcase_30 AC 129 ms
55,568 KB
testcase_31 AC 130 ms
55,780 KB
testcase_32 AC 130 ms
55,576 KB
testcase_33 AC 130 ms
55,544 KB
testcase_34 AC 132 ms
55,812 KB
testcase_35 AC 134 ms
55,808 KB
testcase_36 AC 131 ms
55,776 KB
testcase_37 AC 133 ms
55,876 KB
testcase_38 AC 127 ms
55,836 KB
testcase_39 AC 127 ms
55,816 KB
testcase_40 AC 127 ms
55,972 KB
testcase_41 AC 126 ms
55,908 KB
権限があれば一括ダウンロードができます

ソースコード

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