結果
問題 | No.811 約数の個数の最大化 |
ユーザー | hamuhei4869 |
提出日時 | 2019-04-12 21:44:46 |
言語 | C++11 (gcc 11.4.0) |
結果 |
AC
|
実行時間 | 135 ms / 2,000 ms |
コード長 | 898 bytes |
コンパイル時間 | 1,528 ms |
コンパイル使用メモリ | 154,540 KB |
実行使用メモリ | 4,372 KB |
最終ジャッジ日時 | 2023-10-12 19:30:56 |
合計ジャッジ時間 | 2,851 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,352 KB |
testcase_01 | AC | 2 ms
4,356 KB |
testcase_02 | AC | 99 ms
4,352 KB |
testcase_03 | AC | 1 ms
4,348 KB |
testcase_04 | AC | 2 ms
4,348 KB |
testcase_05 | AC | 3 ms
4,372 KB |
testcase_06 | AC | 7 ms
4,352 KB |
testcase_07 | AC | 10 ms
4,352 KB |
testcase_08 | AC | 44 ms
4,352 KB |
testcase_09 | AC | 50 ms
4,348 KB |
testcase_10 | AC | 29 ms
4,348 KB |
testcase_11 | AC | 96 ms
4,356 KB |
testcase_12 | AC | 23 ms
4,352 KB |
testcase_13 | AC | 135 ms
4,352 KB |
testcase_14 | AC | 112 ms
4,352 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; map< int, int > prime_factor(int n) { map< int, int > ret; for(int64_t i = 2; i * i <= n; i++) { while(n % i == 0) { ret[i]++; n /= i; } } if(n != 1) ret[n] = 1; return ret; } int main(){ int N;cin >> N;int K;cin >> K; map<int,int> mp = prime_factor(N); int yaku = 0; int ans = 1e9; for(int a = 2;a < N;a++){ map<int,int> uku = prime_factor(a); int cnt = 0; for(auto b: uku){ cnt += min(b.second,mp[b.first]); } if(cnt >= K){ int w = 0; for(int b = 1;b <= sqrt(a);b++){ if(b*b == a)w+=1; else if(a%b == 0)w+=2; } // cout<<a<<" "<<w<<endl; if(yaku < w){ yaku = w; ans = a; } } } cout<<ans<<endl; }