-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1454D.cpp
More file actions
45 lines (41 loc) · 1.11 KB
/
Copy path1454D.cpp
File metadata and controls
45 lines (41 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include "bits/stdc++.h"
#pragma GCC optimize "trapv"
using i64 = long long int;
using namespace std;
int nxt(){int x; cin >> x; return x;}
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define inarr(a,n) for(int i = 0; i < n; ++i) cin >> a[i];
//
void solve(){
i64 n;cin >> n;
vector<pair<i64,i64>> a;
// PRIME FACTORIZATION
for (i64 i = 2; i*i <= n; i++){
i64 cnt = 0;
while (n % i == 0){
cnt++;
n = n/i;
}
if(cnt)a.emplace_back(make_pair(cnt,i));
}
if(n>1)a.emplace_back(make_pair(1,n));
sort(rall(a));
//
vector<i64> ans(a[0].first,a[0].second);
for(int i=1;i<sz(a);++i)for(int j=0;j<a[i].first;++j)
ans.back() *= a[i].second;
cout << sz(ans) << "\n";
for(auto& i : ans) cout << i << " ";
}
int main(){
cin.tie(nullptr);cout.tie(nullptr);ios::sync_with_stdio(false);
int testt = 1;
cin >> testt;
for (int i = 0; i < testt; ++i) {
// cout << "Case #" << i << ": ";
solve();
cout << "\n";
}
}