結果

問題 No.811 約数の個数の最大化
ユーザー ldsybldsyb
提出日時 2019-04-13 12:56:49
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 813 bytes
コンパイル時間 1,568 ms
コンパイル使用メモリ 171,444 KB
実行使用メモリ 4,480 KB
最終ジャッジ日時 2023-10-13 11:28:07
合計ジャッジ時間 13,414 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 28 ms
4,352 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
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 = 0;
        for (auto &p : tmp) {
            muni += p.second;
        }
        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