結果

問題 No.811 約数の個数の最大化
ユーザー aaaaaaiuaaaaaaiu
提出日時 2019-08-22 15:26:48
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 650 bytes
コンパイル時間 2,267 ms
コンパイル使用メモリ 201,348 KB
実行使用メモリ 20,608 KB
最終ジャッジ日時 2024-04-20 16:28:42
合計ジャッジ時間 3,234 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 3 ms
5,376 KB
testcase_02 WA -
testcase_03 AC 2 ms
5,376 KB
testcase_04 WA -
testcase_05 AC 3 ms
5,376 KB
testcase_06 WA -
testcase_07 AC 9 ms
5,632 KB
testcase_08 WA -
testcase_09 AC 34 ms
12,160 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 70 ms
20,544 KB
testcase_14 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main() {
    int n,k;
    cin>>n>>k;
    map<int,int> pf[n+1];
    for (int i=1;i<=n;i++) {
        int t=i;
        for (int j=2;j*j<=t;j++)
            while (t%j==0) {
                pf[i][j]++;
                t/=j;
            }
        if (t>1) pf[i][t]++;
    }
    int ans=0;
    int mx=0;
    for (int i=1;i<n;i++) {
        int g=gcd(i,n);
        if (pf[g].size()<k) continue;
        int div=1;
        for (auto p:pf[i])
            div*=p.second+1;
        if (div>mx) {
            ans=i;
            mx=div;
        }
    }
    cout<<ans<<endl;
    return 0;
}
0