fork download
  1. /*
  2. Task: 1454D
  3. Date: Dec 22, 2020
  4. Author: aLittleLove (Minh Vu)
  5. */
  6.  
  7. #include<bits/stdc++.h>
  8. #define rep(i,n) for (int i=0, _n=n; i<_n; i++)
  9. #define FOR(i,a,b) for (int _a=(a), _b=(b), i=_a; _a<=_b?i<=_b:i>=_b; _a<=_b?i++:i--)
  10. #define _mem(a, b) memset(a, (b), sizeof(a))
  11. #define pb push_back
  12. #define fi first
  13. #define se second
  14. #define sz(a) int((a).size())
  15.  
  16. using namespace std;
  17. const int N = 2e5 + 5;
  18. const int inf = 1e9;
  19. const int mod = 1e9 + 7;
  20. const double pi = atan(1) * 4.0;
  21. typedef long long ll;
  22. typedef int64_t i64;
  23. typedef pair<int, int> pii;
  24. typedef vector<pii> vii;
  25. typedef vector<int> vi;
  26. template<typename T, typename U> inline void mini(T &x, U y) { if(y < x) x = y; }
  27. template<typename T, typename U> inline void maxi(T &x, U y) { if(x < y) x = y; }
  28.  
  29. i64 n;
  30. i64 POW(i64 x, i64 y)
  31. {
  32. if (y==0) return 1;
  33. i64 tmp = POW(x, y/2);
  34. if (y&1) return tmp*tmp*x;
  35. return tmp*tmp;
  36. }
  37.  
  38. void Solve()
  39. {
  40. cin >> n;
  41. i64 cur = n;
  42. vector<i64> ans;
  43. i64 base, mx = -1, rem;
  44. for (i64 i=2; i*i<=n; i++)
  45. {
  46. if (n%i==0)
  47. {
  48. for (i64 j=1; j; j++)
  49. {
  50. i64 p = POW(i, j);
  51. if (p>n) break;
  52. if (n%p==0 && (n/p)%i==0 && j>mx)
  53. {
  54. mx = j;
  55. base = i;
  56. rem = n/p;
  57. }
  58. }
  59. }
  60. }
  61. if (mx==-1) cout << 1 << '\n' << n << '\n';
  62. else
  63. {
  64. for (int i=1; i<=mx; i++) ans.pb(base);
  65. if (rem!=1) ans.pb(rem);
  66. cout << sz(ans) << '\n';
  67. for (i64 x: ans) cout << x << " ";
  68. cout << '\n';
  69. }
  70. }
  71.  
  72. int main()
  73. {
  74. ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  75. //freopen("input.txt","r",stdin);
  76. int nTest; cin >> nTest;
  77. while (nTest--) Solve();
  78.  
  79. return 0;
  80. }
Success #stdin #stdout 0s 4968KB
stdin
4
2
360
4999999937
4998207083
stdout
1
2
3
2 2 90 
1
4999999937
1
4998207083