結果
| 問題 |
No.2379 Burnside's Theorem
|
| コンテスト | |
| ユーザー |
tnakao0123
|
| 提出日時 | 2023-07-15 15:59:46 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 7 ms / 2,000 ms |
| コード長 | 1,418 bytes |
| コンパイル時間 | 606 ms |
| コンパイル使用メモリ | 55,724 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-09-17 00:57:23 |
| 合計ジャッジ時間 | 1,605 ms |
|
ジャッジサーバーID (参考情報) |
judge6 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 20 |
ソースコード
/* -*- coding: utf-8 -*-
*
* 2379.cc: No.2379 Burnside's Theorem - yukicoder
*/
#include<cstdio>
#include<vector>
#include<algorithm>
#include<utility>
using namespace std;
/* constant */
const int MAX_P = 1000100;
/* typedef */
typedef long long ll;
typedef vector<int> vi;
typedef pair<ll,int> pli;
typedef vector<pli> vpli;
/* global variables */
bool primes[MAX_P + 1];
/* subroutines */
int gen_primes(int maxp, vi &pnums) {
fill(primes, primes + maxp + 1, true);
primes[0] = primes[1] = false;
int p;
for (p = 2; p * p <= maxp; p++)
if (primes[p]) {
pnums.push_back(p);
for (int q = p * p; q <= maxp; q += p) primes[q] = false;
}
for (; p <= maxp; p++)
if (primes[p]) pnums.push_back(p);
return (int)pnums.size();
}
bool prime_decomp(ll n, vi &pnums, vpli& pds) {
pds.clear();
int pn = pnums.size();
for (int i = 0; i < pn; i++) {
int pi = pnums[i];
if ((ll)pi * pi > n) {
if (n > 1) pds.push_back(pli(n, 1));
return true;
}
if (n % pi == 0) {
int fi = 0;
while (n % pi == 0) n /= pi, fi++;
pds.push_back(pli(pi, fi));
}
}
return false;
}
/* global variables */
/* subroutines */
/* main */
int main() {
vi pnums;
gen_primes(MAX_P, pnums);
ll n;
scanf("%lld", &n);
vpli pds;
prime_decomp(n, pnums, pds);
if (pds.size() <= 2) puts("Yes");
else puts("No");
return 0;
}
tnakao0123