题目描述:
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≤109).
输出描述:
5
64
32
97
2
12345
输入:
YES
2 4 8
NO
NO
NO
YES
3 5 823
输出:
1
4
题意:
给你一个整数n。找出三个不同的整数a、b、c,使得2≤a、b、c和a⋅b⋅c=n,或者说这是不可能的。
题解
直接在因子里面搜就好了
代码:

#include<cstdio>
#include<vector>
#include<set>
#include<iostream>
#include<algorithm>
using namespace std;int main(){int t,n;scanf("%d",&t);while(t--){vector<int> v;set<int>s;scanf("%d",&n);for(int i = 2; i * i <= n; i ++){if(n % i == 0){v.push_back(i);s.insert(i);s.insert(n / i);}}bool flag = false;for(int i = 0; i < v.size(); i ++){for(int j = i + 1; j < v.size(); j ++){int num = v[i] * v[j];int cnt = n / num;if(n % cnt == 0 && cnt != v[i] && cnt != v[j] && s.find(cnt) != s.end()){printf("YES\n");flag = true;printf("%d %d %d\n", v[i], v[j], cnt);break;}}if(flag) break;}if(!flag) printf("NO\n");}return 0;
}

Codeforces--1294C--Product of Three Numbers相关推荐

  1. Educational Codeforces Round 8 D. Magic Numbers 数位DP

    D. Magic Numbers 题目连接: http://www.codeforces.com/contest/628/problem/D Description Consider the deci ...

  2. LeetCode 628. Maximum Product of Three Numbers

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

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

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

  4. Codeforces 446C —— DZY Loves Fibonacci Numbers(线段树)

    题目:DZY Loves Fibonacci Numbers 题意比較简单,不解释了. 尽管官方的题解也是用线段树,但还利用了二次剩余. 可是我没有想到二次剩余,然后写了个感觉非常复杂度的线段树,还是 ...

  5. 【CodeForces - 244B】Undoubtedly Lucky Numbers (dfs打表 + 二分)

    题干: Polycarpus loves lucky numbers. Everybody knows that lucky numbers are positive integers, whose ...

  6. Codeforces 446C. DZY Loves Fibonacci Numbers【斐波那契+线段树】

    C. DZY Loves Fibonacci Numbers [题目描述] 传送门 [题解] 我们可以知道斐波那契数列有两个性质: ∑i=1nFi=Fn+2−F2\sum_{i=1}^{n} F_i= ...

  7. Codeforces 446C. DZY Loves Fibonacci Numbers (Fibonacci + 线段树)

    Description In mathematical terms, the sequence F n of Fibonacci numbers is defined by the recurrenc ...

  8. C. Product of Three Numbers

    Problem - C - Codeforces You are given one integer number nn. Find three distinct integers a,b,ca,b, ...

  9. codeforces #235 D. Roman and Numbers 题解

    转载请注明:http://blog.csdn.net/jiangshibiao/article/details/23100595 [原题] D. Roman and Numbers time limi ...

  10. Codeforces 1182E Product Oriented Recurrence 矩阵快速幂

    Product Oriented Recurrence 先化简原式子 c ^ x * f[x]  = c ^ (x-1) * f[x-1] * c ^ (x-2) * f[x-2] * c ^ (x- ...

最新文章

  1. Python实战案例,requests模块,Python实现获取动态图表
  2. DWRUtil的方法使用说明
  3. 咸鱼翻身 汉能薄膜是如何做到的?
  4. C#实现多态之一抽象
  5. 《操作系统实现之路》源代码下载路径及求助途径
  6. ABAP很厉害是怎么一种体验?
  7. 微软高管解读财报:努力创新云基础架构
  8. 只需5步,轻松创建HTML5离线应用
  9. Google Chrome调试js代码
  10. 基于自然语言识别下的流失用户预警
  11. WAS6.1在JDK1.5环境下JSP无法编译问题
  12. linux查分自动备份tar,linux 下tar的增量备份
  13. [转载]无线通信系统中的调制解调基础(一):AM和FM
  14. DXUT框架剖析(11)
  15. WPF 加载Gif动态图片的方法
  16. 电脑键盘部分按键失灵_笔记本键盘失灵怎么办,电脑键盘失灵-中关村在线
  17. 计算机cpu intel,intel CPU后面带F是什么意思?Intel处理器后面带“F”含义详解
  18. 从抢票软件到浏览器设计
  19. OpenStack------Placement组件部署
  20. 读王蒙的《庄子的快活》

热门文章

  1. Docker - Docker Container及Container命令详解
  2. csgo服务器搭建文件,CSGO服务器架设.doc
  3. HDLBits-Exams/ece241 2013 q4、Lemmings1、Lemmings2、Lemmings3、Lemmings4
  4. (c语言)通俗易懂的冒泡代码思路
  5. 智能温室的优缺点,你都知道哪些?
  6. 优化elelment ui 的 dialog 样式
  7. postgreSql数据库笔记
  8. 【Python学习笔记(二)】使用Pyinstaller将不同路径下的py文件打包成exe可执行文件
  9. Spring IoC注入三种方式
  10. LNK2001LNK2019