結果
| 問題 |
No.811 約数の個数の最大化
|
| コンテスト | |
| ユーザー |
sinsincoscos
|
| 提出日時 | 2019-04-12 23:18:02 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 45 ms / 2,000 ms |
| コード長 | 934 bytes |
| コンパイル時間 | 735 ms |
| コンパイル使用メモリ | 80,428 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-09-15 06:17:59 |
| 合計ジャッジ時間 | 1,577 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 12 |
ソースコード
#include <iostream>
#include <map>
#include <vector>
using namespace std;
typedef pair<int,int> P;
int N,K;
map<int,int> m;
int main(){
cin >> N >> K;
int n = N;
for(int i=2;i*i<=N;i++){
while(n%i==0){
n /= i;
m[i]++;
}
}
if(n!=1) m[n]++;
int ans = 1e9,ma = 0;
for(int i=2;i<N;i++){
int n2 = i;
map<int,int> m2;
for(int j=2;j*j<=n2;j++){
while(n2%j==0){
n2 /= j;
m2[j]++;
}
}
if(n2!=1) m2[n2]++;
int num = 1,cnt = 0;
for(auto x:m2){
num *= x.second+1;
if(m.count(x.first)) cnt += min(m[x.first],x.second);
}
//cerr << i << " " << num << " " << cnt << endl;
if(cnt<K) continue;
if(ma<num) ans = i;
if(ma==num) ans = min(ans,i);
ma = max(ma,num);
}
cout << ans << endl;
}
sinsincoscos