結果

問題 No.811 約数の個数の最大化
ユーザー totori_nyaatotori_nyaa
提出日時 2019-04-12 22:56:43
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 757 bytes
コンパイル時間 1,413 ms
コンパイル使用メモリ 165,372 KB
実行使用メモリ 4,392 KB
最終ジャッジ日時 2023-10-13 08:57:11
合計ジャッジ時間 10,402 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

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

int main(){
    long long n,k;
    cin>>n>>k;
    int a[n+1]={};
    long long t=n;

    for(int i=2;i<=n;i++){
        while(n%i==0){
            a[i]++;
            n/=i;
        }
    }

    int m=0;
    int ans=0;

    for(int i=t-2;i>=2;i-=2){
        int c=0;
        int cnt=1;
        int g=i;
        int b[g+1]={};

        for(int j=2;j<=g;j++){
            while(g%j==0){
                g/=j;
                b[j]++;
            }
            if(a[j]){
                c+=min(a[j],b[j]);
            }
            cnt*=b[j]+1;
        }
       
        if(c>=k && cnt>=m){
            ans=i;
            m=cnt;
            //cerr<<i<<" "<<cnt<<" "<<c<<endl;
        }
    }

    cout<<ans<<endl;

}
0