Submit Info #2624

Problem Lang User Status Time Memory
Factorize cpp mdstoy CE -1 ms -1 Mib

ケース詳細
Name Status Time Memory

#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; #define FOR(i, m, n) for (int i = (m); i < (n); i++) #define FORR(i, m, n) for (int i = (m); i >= (n); i--) #define REP(i, n) FOR(i, 0, (n)) #define REPR(i, n) FORR(i, (n) - 1, 0) #define REP1(i, n) FOR(i, 1, (n) + 1) #define REPS(c, s) for (char c : s) #define ALL(c) (c).begin(), (c).end() #define sz(v) (int)v.size() template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;} template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;} const int MOD = 1000000007; const int INF = 1000000001; const ll LINF = 1000000001000000001LL; const char EOL = '\n'; void solve(); int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cout << fixed << setprecision(numeric_limits<double>::max_digits10); solve(); return 0; } multiset<ll> prime_factorization(ll n) { multiset<ll> m; ll x = n; ll d = 2; while (x > 1 && d * d <= n) { if (x % d == 0) { m.emplace(d); x /= d; } else { d++; } } if (x != 1) m.emplace(x); return m; } void solve() { int q; cin >> q; while (q--) { ll a; cin >> a; if (a == 1) { cout << 0 << EOL; continue; } multiset<ll> p = prime_factorization(a); cout << sz(p) << " "; for (auto q : p) { cout << q << ' '; } cout << EOL; }