CF1454D.Number into Sequence
普及-
通过率:0%
时间限制:3.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given an integer n (n>1).
Your task is to find a sequence of integers a1,a2,…,ak such that:
- each ai is strictly greater than 1;
- a1⋅a2⋅…⋅ak=n (i. e. the product of this sequence is n);
- ai+1 is divisible by ai for each i from 1 to k−1;
- k is the maximum possible (i. e. the length of this sequence is the maximum possible).
If there are several such sequences, any of them is acceptable. It can be proven that at least one valid sequence always exists for any integer n>1.
You have to answer t independent test cases.
给你一个整数 n(n>1)。
你的任务是找出一个整数序列 a1,a2,…,ak,满足以下条件:
- 每个 ai 严格大于 1;
- a1⋅a2⋅…⋅ak=n(即该序列的乘积等于 n);
- 对每个从 1 到 k−1 的 i,均有 ai+1 被 ai 整除;
- k 尽可能大(即该序列的长度达到最大可能值)。
若存在多个满足条件的序列,输出任意一个即可。可以证明:对任意大于 1 的整数 n,至少存在一个合法序列。
你需要回答 t 个相互独立的测试用例。
输入格式
The first line of the input contains one integer t (1≤t≤5000) — the number of test cases. Then t test cases follow.
The only line of the test case contains one integer n (2≤n≤1010).
It is guaranteed that the sum of n does not exceed 1010 (∑n≤1010).
输入的第一行包含一个整数 t(1≤t≤5000),表示测试用例的数量。接下来是 t 个测试用例。
每个测试用例仅有一行,包含一个整数 n(2≤n≤1010)。
保证所有测试用例中 n 的总和不超过 1010(即 ∑n≤1010)。
输出格式
For each test case, print the answer: in the first line, print one positive integer k — the maximum possible length of a. In the second line, print k integers a1,a2,…,ak — the sequence of length k satisfying the conditions from the problem statement.
If there are several answers, you can print any. It can be proven that at least one valid sequence always exists for any integer n>1.
对于每个测试用例,请输出答案:第一行输出一个正整数 k —— 序列 a 的最大可能长度;第二行输出 k 个整数 a1,a2,…,ak —— 一个长度为 k 且满足题目所述条件的序列。
若存在多个合法答案,输出任意一个即可。可以证明:对任意整数 n>1,至少存在一个合法序列。
输入输出样例
输入#1
4 2 360 4999999937 4998207083
输出#1
1 2 3 2 2 90 1 4999999937 1 4998207083
输入解题思路,AI测评打分。不知道怎么写?