1454D - Number into Sequence // 思路 如果不考虑a数组元素之间的整除关系,a数组就是n根据唯一分解定理 分解后的结果。 所以 假设 n = a1^p1 * a2 ^ p2 * ... * an ^ pn 只要找到max(p1,p2...pn),假设为p,对应的底数为a。 可以构建的数组就是:(p - 1) 个 a,最后一个数就是 a * (其他的所有数)。 #include<iostream> #include<cstring> using namespace std; typedef long long ll; const int N = 1000010; int main() { int t; cin >> t; while(t --) { ll n; cin >> n; int mx = 0; ll k = n; int tt; for(ll i = 2; i * i <= n; i ++) { int p = 0; while(n % i == 0) { n /= i; p ++; } if(mx < p) { tt = i; mx = p; } } if(n) { if(mx < 1) mx = 1,tt = n; } cout << mx << endl; ll res = 1; for(int j = 1; j < mx; j ++) { cout << tt << ' '; res *= tt; } cout << k / res << endl; } }