結果

問題 No.136 Yet Another GCD Problem
ユーザー Goryudyuma
提出日時 2015-04-21 12:31:54
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 357 bytes
コンパイル時間 507 ms
コンパイル使用メモリ 56,408 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-04 19:07:10
合計ジャッジ時間 1,917 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 12 WA * 27
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>

using namespace std;


int main()
{
	int N, M;
	cin >> N >> M;
	int ans = max(1, N / M);
	if (ans == 1)
	{
		cout << 1 << endl;
	} else
	{
		while (1)
		{
			if (!((N - ans*(M - 1)) % ans))
			{
				cout << ans << endl;
				break;
			}
			ans--;
			if (ans == 1)
			{
				cout << 1 << endl;
			}
		}
	}
	return 0;
}
0