結果

問題 No.811 約数の個数の最大化
ユーザー merom686merom686
提出日時 2019-04-12 23:20:23
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 153 ms / 2,000 ms
コード長 757 bytes
コンパイル時間 586 ms
コンパイル使用メモリ 73,272 KB
実行使用メモリ 4,356 KB
最終ジャッジ日時 2023-10-13 09:10:53
合計ジャッジ時間 2,079 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 134 ms
4,352 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 3 ms
4,352 KB
testcase_06 AC 6 ms
4,348 KB
testcase_07 AC 9 ms
4,348 KB
testcase_08 AC 54 ms
4,348 KB
testcase_09 AC 57 ms
4,352 KB
testcase_10 AC 33 ms
4,348 KB
testcase_11 AC 131 ms
4,352 KB
testcase_12 AC 25 ms
4,348 KB
testcase_13 AC 153 ms
4,356 KB
testcase_14 AC 153 ms
4,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

int main() {
    int n, k;
    cin >> n >> k;

    int r = -1;
    ll m = 0;
    for (int i = 1; i < n; i++) {
        int t = i, s = n, y = 0;
        ll c = 1;
        for (int j = 2; j * j <= n; j++) {
            int h = 0;
            while (t % j == 0) {
                if (s % j == 0) s /= j, y++;
                t /= j, h++;
            }
            c *= h + 1;
        }
        if (s > 1 && t > 1 && s % t == 0) y++;
        if (t > 1) c *= 2;
        if (y >= k && c > m) {
            m = c;
            r = i;
        }
    }

    cout << r << endl;

    return 0;
}
0