C. Product of Three Numbers【1300 / 简单数论】

C. Product of Three Numbers【1300 / 简单数论】
https://codeforces.com/problemset/problem/1294/C

#include<bits/stdc++.h>
using namespace std;
int main(void) 
{
	int t; cin>>t;
	while(t--)
	{
		int n; cin>>n;
		bool flag=0;
		for(int i=2;i<=n/i;i++)
		{
			if(n%i==0)
			{
				int temp=n/i;
				for(int j=2;j<=temp/j;j++) 
				{
					if(temp%j==0)
					{
						int a=i,b=j,c=temp/j;
						if(a==b||a==c||b==c) continue;
						puts("YES");
						cout<<j<<" "<<temp/j<<" "<<i<<endl;
						flag=1;
						break;
					}
				}
			}
			if(flag) break;
		}
		if(!flag) puts("NO");
	}
	return 0;
}
上一篇:AT5759 ThREE 题解


下一篇:[LeetCode 解题笔记] 1. Two Sum