This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
#include <bits/stdc++.h>
using namespace std;
/**
测试数据:12
参考答案:
2 2 3
3
*/
//埃拉筛
const int N = 1e5 + 10;
int primes[N], cnt; // primes[]存储所有素数
bool st[N]; // st[x]存储x是否被筛掉
void get_primes(int n) {
for (int i = 2; i <= n; i++)
if (!st[i]) {
//记录素数
primes[cnt++] = i;
//成倍数的标识
for (int j = 2 * i; j <= n; j += i) st[j] = true;
}
int main() {
int n;
cin >> n;
get_primes(n);
int c = 0;
for (int i = 0; i < cnt; i++) {
while (n % primes[i] == 0) {
n /= primes[i];
cout << primes[i] << " ";
c++;
cout << endl;
cout << c << endl;
return 0;