Problem - C - Codeforces

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
思路:因为有三个数,如果该数的两个约数都为素数,那么不可能有三个,必定为no。若两个约束里至少有一个不是素数,那么把该数拆分成两个约数,再输出另一个数即可,但是要判断都不相等。
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
ll n,m;
int t;
bool  is_prime(ll n)//试除法判断是不是约数
{if(n==1)return false;if(n==2)return true;for(int i=2;i<=n/i;i++){if(n%i==0){return false;}}return true;
}
bool getdive(ll n,ll x)//如果不是素数,那就把这个数拆成两个约数
{for(int i=2;i<n/i;i++){if(n%i==0&&n/i!=i&&n/i!=x&&i!=x){cout<<"YES"<<endl;cout<<i<<" "<<n/i<<" ";return true;}}return false;
}
void get_divisorts(ll n)
//先找到两个约数,然后判断这两个约数一个一个判断是不是素数for(ll i=1;i<=n/i;i++){if(n%i==0&&n/i!=i){if(!is_prime(i)){if(getdive(i,n/i)){cout<<n/i<<endl;return;}}else if(!is_prime(n/i)){if(getdive(n/i,i)){cout<<i<<endl;return;}}else {cout<<"NO"<<endl;return ;}}}cout<<"NO"<<endl;return ;
}
int main()
{cin>>t;while(t--){cin>>m;get_divisorts(m);}return 0;
}

C. Product of Three Numbers相关推荐

  1. LeetCode 628. Maximum Product of Three Numbers

    题目: Given an integer array, find three numbers whose product is maximum and output the maximum produ ...

  2. C#LeetCode刷题之#628-三个数的最大乘积( Maximum Product of Three Numbers)

    问题 该文章的最新版本已迁移至个人博客[比特飞],单击链接 https://www.byteflying.com/archives/3726 访问. 给定一个整型数组,在数组中找出由三个数组成的最大乘 ...

  3. 628. Maximum Product of Three Numbers

  4. leetcode 628. Maximum Product of Three Numbers | 628. 三个数的最大乘积(Java)

    题目 https://leetcode-cn.com/problems/maximum-product-of-three-numbers/ 题解 找到三个数的最大乘积.先给数组排序,考虑可能有负数的情 ...

  5. Product of Three Numbers(CF-1294C)

    Problem Description You are given one integer number n. Find three distinct integers a,b,c such that ...

  6. ACdream 1431 Sum vs Product

    题目链接:http://115.28.76.232/problem? pid=1431 Sum vs Product Time Limit: 4000/2000MS (Java/Others)Memo ...

  7. 计算机数学基础①(Numbers)

    文章目录 Numbers Integers Even and Odd Integers Divisibility and Primes(可分性和质数) Modular Arithmetic(模运算) ...

  8. 全球第五大社交网站,二号员工离职创业,自爆心酸历程!想做10亿美元规模?先活着!...

    大表姐导读:创业者不易,创业故事更加珍贵.美国Pinterest,全球第五大社交网站,图片版Twitter,工号第2号员工从0到1出来创业.自爆心酸历程.从昔日的明星创业公司沦落到公司只剩他一人.资产 ...

  9. 如何实现科技论文里面的算法

    如何实现科技论文里面的算法 这是一篇关于如何实现科研论文中算法的简要指南.作者曾实现过很多书本上和科研论文中的复杂算法,在这篇文章中作者总结他在研究,阅读,编码和调试时积累的大量经验.很显然,这篇文章 ...

最新文章

  1. 设计模式之代理模式学习笔记
  2. 上周热点回顾(7.10-7.16)
  3. SpringMVC对Ajax请求的处理
  4. 大数据,TB、PB、EB
  5. AcWing 889. 满足条件的01序列(卡特兰数)
  6. 51. Element replaceChild() 方法
  7. ppt格式刷快捷键_15个PPT神操作,让老师做课件的效率翻倍!
  8. AUTOCAD——光顺曲线命令、分解命令
  9. 数据的展现技巧——数据透视表(一)
  10. 苹果cms对接双端android源码,苹果cms影视双端APP搭建教程
  11. Ubuntu 搭建opengrok 流程
  12. 淘宝订单信息获取接口,淘宝开放平台R2权限,淘宝开放平台订单获取接口
  13. 卸载奇安信360天擎
  14. VLAN网络支持ipv6的交换机和虚机配置
  15. 莫做井底之蛙,网站推广之外链不是全部
  16. 以太网的定义、分类和检测——TFN T200K 手持千兆以太网测试仪
  17. 相机与图像--小孔成像模型与坐标系--坐标系转换
  18. 32位系统加载不了64位的dll。。。是不是没有为此架构安装?
  19. golang colly踩坑笔记
  20. 中国系统java开发面试准备

热门文章

  1. CodeBlocks调试功能快捷教程
  2. 从零开始掌握Python机器学习:七步教程 基础篇
  3. 阿里云ECS学习笔记1
  4. YOLOv5火焰识别
  5. Win32病毒入门 -- ring3篇
  6. MY SQL 数据库升级
  7. MBR、EBR、DBR
  8. 直观说明Hadoop是什么?有什么作用?
  9. 八种基本数据类型(一)
  10. operator++()实现:前置++和后置++