結果

問題 No.136 Yet Another GCD Problem
ユーザー YamaKasa
提出日時 2018-07-17 17:57:57
言語 Java
(openjdk 23)
結果
AC  
実行時間 135 ms / 5,000 ms
コード長 371 bytes
コンパイル時間 2,033 ms
コンパイル使用メモリ 73,964 KB
実行使用メモリ 41,572 KB
最終ジャッジ日時 2024-11-25 20:12:43
合計ジャッジ時間 8,619 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 39
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int K = scan.nextInt();
		scan.close();
		if(K == 1) {
			System.exit(0);
		}
		int ans = 1;
		for(int i = N - 1; i >= 2; i--) {
			if(N % i == 0) {
				ans = i;
				break;
			}
		}
		System.out.println(ans);
	}
}
0