結果
| 問題 |
No.36 素数が嫌い!
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-02-10 04:32:24 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 50 ms / 5,000 ms |
| コード長 | 711 bytes |
| コンパイル時間 | 544 ms |
| コンパイル使用メモリ | 62,312 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-06-27 00:41:12 |
| 合計ジャッジ時間 | 1,755 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 26 |
ソースコード
#include <cmath>
#include <cstdint>
#include <cstdlib>
#include <iostream>
static int
countFactors(std::uint64_t n);
int
main()
{
std::cin.tie(0);
std::ios::sync_with_stdio(false);
std::uint64_t n;
std::cin >> n;
std::cout << (countFactors(n) > 3 ? "YES" : "NO") << std::endl;
return EXIT_SUCCESS;
}
static int
countFactors(std::uint64_t n)
{
int cnt = 1;
for (; n % 2 == 0; n /= 2, cnt++);
for (std::uint64_t i = 3, iMax = static_cast<std::uint64_t>(std::sqrt(n)) + 2; i <= iMax; i += 2) {
int subcnt = 0;
for (; n % i == 0; n /= i, subcnt++);
if (subcnt != 0) {
cnt += subcnt;
iMax = std::sqrt(n) + 2;
}
}
if (n != 1) {
cnt++;
}
return cnt;
}