結果
問題 | No.811 約数の個数の最大化 |
ユーザー | hiroa |
提出日時 | 2019-05-03 09:00:34 |
言語 | C++14 (gcc 13.2.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 122 ms / 2,000 ms |
コード長 | 714 bytes |
コンパイル時間 | 1,605 ms |
コンパイル使用メモリ | 169,172 KB |
実行使用メモリ | 12,844 KB |
最終ジャッジ日時 | 2023-08-30 05:04:17 |
合計ジャッジ時間 | 3,375 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,376 KB |
testcase_01 | AC | 2 ms
4,376 KB |
testcase_02 | AC | 106 ms
12,264 KB |
testcase_03 | AC | 2 ms
4,380 KB |
testcase_04 | AC | 2 ms
4,380 KB |
testcase_05 | AC | 3 ms
4,376 KB |
testcase_06 | AC | 7 ms
4,380 KB |
testcase_07 | AC | 10 ms
4,380 KB |
testcase_08 | AC | 47 ms
7,604 KB |
testcase_09 | AC | 51 ms
7,732 KB |
testcase_10 | AC | 31 ms
6,240 KB |
testcase_11 | AC | 106 ms
11,992 KB |
testcase_12 | AC | 24 ms
5,604 KB |
testcase_13 | AC | 122 ms
12,780 KB |
testcase_14 | AC | 121 ms
12,844 KB |
ソースコード
#include<bits/stdc++.h> using namespace std; typedef long long ll; #define MOD 1000000007 #define INF 1e9 int main(){ int N,K; cin>>N>>K; vector<vector<int>> fact(N); vector<int> num(N,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); } } num[1]=0; 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; }