結果
| 問題 |
No.811 約数の個数の最大化
|
| コンテスト | |
| ユーザー |
Bwambocos
|
| 提出日時 | 2019-04-12 21:46:45 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 192 ms / 2,000 ms |
| コード長 | 944 bytes |
| コンパイル時間 | 1,722 ms |
| コンパイル使用メモリ | 176,652 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-09-14 17:58:29 |
| 合計ジャッジ時間 | 2,994 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 12 |
コンパイルメッセージ
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/istream:39,
from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/sstream:38,
from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/complex:45,
from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/ccomplex:39,
from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/x86_64-pc-linux-gnu/bits/stdc++.h:54,
from main.cpp:1:
In member function 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long int) [with _CharT = char; _Traits = std::char_traits<char>]',
inlined from 'int main()' at main.cpp:59:9:
/home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/ostream:202:25: warning: 'ansN' may be used uninitialized [-Wmaybe-uninitialized]
202 | { return _M_insert(__n); }
| ~~~~~~~~~^~~~~
main.cpp: In function 'int main()':
main.cpp:44:12: note: 'ansN' was declared here
44 | LL ansN, ansC = 0;
| ^~~~
ソースコード
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;
std::map<LL, LL> decomposit_prime(LL n)
{
LL d = 2;
std::map<LL, LL>res;
while (d * d <= n)
{
if (n % d == 0)
{
++res[d];
n /= d;
}
else ++d;
}
++res[n];
return res;
}
std::vector<LL>divisor(LL num)
{
std::vector<LL>res;
for (LL i = 1; i * i <= num; ++i)
{
if (num % i == 0)
{
res.push_back(i);
if ((num / i) != i) res.push_back(num / i);
}
}
return res;
}
int main()
{
LL N, K;
in >> N >> K;
auto N_primes = decomposit_prime(N);
LL ansN, ansC = 0;
for (LL i = 1; i < N; ++i)
{
auto M_primes = decomposit_prime(i);
LL same = 0;
for (auto j : M_primes) same += std::min(j.second, N_primes[j.first]);
if (same < K) continue;
auto M_divs = divisor(i);
if (ansC < M_divs.size())
{
ansN = i;
ansC = M_divs.size();
}
}
out << ansN << std::endl;
}
Bwambocos