题目链接:codeforces 1294C
题目:
You are given one integer number n. Find three distinct integers a,b,c such that 2≤a,b,c and a⋅b⋅c=n or say that it is impossible to do it.
If there are several answers, you can print any.
You have to answer t independent test cases.
输入
The first line of the input contains one integer t (1≤t≤100) — the number of test cases.
The next n lines describe test cases. The i-th test case is given on a new line as one integer n (2≤n≤10^9).
输出
For each test case, print the answer on it. Print “NO” if it is impossible to represent n as a⋅b⋅c for some distinct integers a,b,c such that 2≤a,b,c.
Otherwise, print “YES” and any possible such representation.
题目大意:在T个样例内,每个样例给定一个数字,如果能找到找到一组都大于1且不同的整数abc,使得a* b *c=n 输出YES 并给出对应的值 否则输出NO
样例
Input
5
64
32
97
2
12345
Output
YES
2 4 8
NO
NO
NO
YES
3 5 823
思路:分解质因数的想法,并用集合set来得到不同的数字。判断集合中是否有三个值,若有则YES,无则NO
代码如下:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
set<