結果

問題 No.811 約数の個数の最大化
ユーザー Shuz*Shuz*
提出日時 2019-03-15 11:56:51
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 718 bytes
コンパイル時間 1,584 ms
コンパイル使用メモリ 170,456 KB
実行使用メモリ 12,892 KB
最終ジャッジ日時 2023-09-22 04:39:46
合計ジャッジ時間 3,031 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 108 ms
11,928 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 3 ms
4,380 KB
testcase_06 AC 7 ms
4,380 KB
testcase_07 AC 10 ms
4,380 KB
testcase_08 AC 49 ms
7,552 KB
testcase_09 WA -
testcase_10 AC 33 ms
6,368 KB
testcase_11 AC 108 ms
12,028 KB
testcase_12 AC 25 ms
5,684 KB
testcase_13 AC 123 ms
12,892 KB
testcase_14 AC 122 ms
12,772 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main() {
    int N, K;
    cin >> N >> K;
    vector<vector<int>> fact(N + 1);
    vector<int> num(N + 1, 1);
    for (int i = 1; i < N; i++) {
        for (int j = 1; j * j <= i; j++) {
            if (i % j) continue;
            fact[i].push_back(j);
            if (j * j != i) fact[i].push_back(i / j);
        }
    }
    for (int i = 2; i * i < N; i++) {
        if (num[i] != 1) continue;
        for (int j = 2; i * j < N; j++) num[i * j] = num[i] + num[j];
    }
    int max = 0, res = 0;
    for (int i = 1; i < N; i++) {
        if (num[__gcd(i, N)] >= K && fact[i].size() > max)
            res = i, max = fact[i].size();
    }
    cout << res << endl;
}
0