C. Product of Three Numbers

链接:https://codeforces.com/contest/1294/problem/C

You are given one integer number nn. Find three distinct integers a,b,ca,b,c such that 2≤a,b,c2≤a,b,c and a⋅b⋅c=na⋅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 tt independent test cases.

Input

The first line of the input contains one integer tt (1≤t≤1001≤t≤100) — the number of test cases.

The next nn lines describe test cases. The ii-th test case is given on a new line as one integer nn (2≤n≤1092≤n≤109).

Output

For each test case, print the answer on it. Print "NO" if it is impossible to represent nn as a⋅b⋅ca⋅b⋅c for some distinct integers a,b,ca,b,c such that 2≤a,b,c2≤a,b,c.

Otherwise, print "YES" and any possible such representation.

Example

input

Copy

5
64
32
97
2
12345

output

Copy

YES
2 4 8 
NO
NO
NO
YES
3 5 823 

代码:

#include<bits/stdc++.h>
using namespace std;
long long n,t,k,b,c,s,x1,x2;
map<long long,long long>m,l;
long long a[10000001];
int main()
{
	cin>>t;
	while(t--)
	{
		cin>>n;
		k=pow(n,1.0/2);
		x1=0;
		x2=0;
		int flag=0;
		for(int i=2;i<=k;i++)
		{
			if(n%i==0)
			{
				if(x1==0)
				{
					x1=i;
					n/=i;
				}
				else
				{
					if(x1*i!=n&&i*i!=n&&n!=i)
					{
						x2=i;
						n/=i;
						flag=1;
						break;
					}
				}
			}
		}
		if(flag==1)
		{
			cout<<"YES"<<endl;
			cout<<x1<<" "<<x2<<" "<<n<<endl;
		}
		else
		{
			cout<<"NO"<<endl;
		}
	}
	
}

 

发布了199 篇原创文章 · 获赞 20 · 访问量 1万+
展开阅读全文

没有更多推荐了,返回首页

©️2019 CSDN 皮肤主题: 精致技术 设计师: CSDN官方博客

分享到微信朋友圈

×

扫一扫,手机浏览