結果

問題 No.811 約数の個数の最大化
ユーザー ldsybldsyb
提出日時 2019-04-13 13:01:08
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 636 bytes
コンパイル時間 1,572 ms
コンパイル使用メモリ 171,516 KB
実行使用メモリ 4,356 KB
最終ジャッジ日時 2023-10-13 11:34:36
合計ジャッジ時間 14,611 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 TLE -
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 6 ms
4,352 KB
testcase_06 AC 33 ms
4,352 KB
testcase_07 AC 63 ms
4,352 KB
testcase_08 AC 678 ms
4,348 KB
testcase_09 AC 755 ms
4,348 KB
testcase_10 AC 366 ms
4,348 KB
testcase_11 TLE -
testcase_12 AC 251 ms
4,352 KB
testcase_13 TLE -
testcase_14 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main()
{
	int n, k;
	cin >> n >> k;
	map<int, int> mp;
	for (int i = 2, j = n; j != 1; i++)
	{
		while (j % i == 0)
		{
			mp[i]++;
			j /= i;
		}
	}
	int num = 0, ans = 0;
	for (int i = 2; i < n; i++)
	{
		map<int, int> tmp;
		for (int j = 2, k = i; k != 1; j++)
		{
			while (k % j == 0)
			{
				tmp[j]++;
				k /= j;
			}
		}
		int puni = 0, muni = 1;
		for (auto &p : tmp)
		{
			muni *= (p.second + 1);
		}
		for (auto &p : mp)
		{
			puni += min(p.second, tmp[p.first]);
		}
		if (k <= puni && num < muni)
		{
			num = muni;
			ans = i;
		}
	}
	cout << ans << endl;
	return 0;
}
0