Product of Three Numbers

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.

Input
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≤109).

Output
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.

Example
Input
5
64
32
97
2
12345
Output
YES
2 4 8
NO
NO
NO
YES
3 5 823
问你能否使用三个不同的数字,使得三个数字的乘积刚好为这个数,如果满足输出YES并且输出三个数字,否则输出NO

#include"bits/stdc++.h"
using namespace std;
int main()
{
	int t;
	int a,b,c,n,x[4];
	cin>>t;
	while(t--)
	{
		cin>>n;
		//int flag=0;
		if(n<24)
		{
			cout<<"NO"<<endl;
			continue;
		}
		else
		{
			a=0,b=0;
			for(int i=2;i<=n/i;i++)
			{
				if(n%i==0)
				{
					a=i;
					break;
				}
			}
			if(a==0)
			{
				cout<<"NO"<<endl;
				continue;
			}
			n/=a;
			for(int i=a+1;i<n/i;i++)
			{
				if(n%i==0)
				{
					b=i;
					break;
				}
			 } 
			 if(b==0)
			 {
			 	cout<<"NO"<<endl;
			 }
			 else
			 {
			 	c=n/b;
				cout<<"YES"<<endl;
				cout<<a<<" "<<b<<" "<<c<<endl; 
			 }
		}
	}
	return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Product of Experts (PoE) 是一种概率图模型,用于建模复杂的概率分布。它基于将多个专家模型组合起来形成的更强大的模型。 PoE的基本思想是将多个概率分布乘在一起,从而形成更复杂的模型。这些概率分布通常被称为专家模型,它们可以是任意类型的概率模型,如高斯模型、混合模型等等。通过将这些专家模型相乘,可以得到一个更一般化、更灵活的模型,可以更好地适应复杂的数据分布。 PoE的核心概念是独立性假设。它假设各个专家模型是独立的,即它们互不影响,只是对数据的不同方面进行建模。这使得PoE可以将问题分解为多个更易解决的子问题,每个专家模型负责解决一个子问题。专家模型之间的独立性也使得PoE的计算更加高效。 PoE的训练过程通常涉及最大似然估计或变分推断。通过最大化数据的似然函数,可以得到最优的专家模型参数,从而得到最佳的整体模型。变分推断可以用于近似计算,以处理模型的复杂性。 PoE在建模和推断方面具有很大的灵活性和表达能力。它可以适应各种复杂数据,并可以通过增加或减少专家模型来调整模型的复杂度。这使得PoE在许多领域中得到了广泛的应用,如计算机视觉、自然语言处理等。 总之,PoE通过将多个专家模型相乘,形成更强大的概率分布模型。它的独立性假设和灵活的建模能力使得它成为处理复杂数据的有力工具。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值