113. Nearly prime numbers

time limit per test: 0.25 sec.
memory limit per test: 4096
KB

Nearly prime number is an integer positive number for which it is possible to find such primes P1 and P2 that given number is equal to P1*P2. There is given a sequence on N integer positive numbers, you are to write a program that prints “Yes” if given number is nearly prime and “No” otherwise.

Input

Input file consists of N+1 numbers. First is positive integer N (1£N£10). Next N numbers followed by N. Each number is not greater than 109. All numbers separated by whitespace(s).

Output

Write a line in output file for each number of given sequence. Write
“Yes” in it if given number is nearly prime and “No” in other case.

Sample Input

1
 #include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std; int n; bool judge(int x) {
int sum = ;
int t;
for(int i = ; i * i <= x; i++) {
if(x % i == ) {
sum++;
t = i; }
} return sum == && ((x / t == t) || x / t % t != ) ;
}
int main()
{ scanf("%d",&n); for(int i = ; i <= n; i++) {
int ch;
scanf("%d",&ch);
if(judge(ch)) printf("Yes\n");
else printf("No\n");
}
return ;
}
6

Sample Output

Yes

 易知,我们要寻找的数除1 与自身外其他的因子数必然不超过2,假设有两个因子,则其中一个因子必然不能整除另一个因子。

SGU 113的更多相关文章

  1. Nearly prime numbers - SGU 113(素数)

    题目大意:判断一个数是否是两个素数的乘积,如果是,输出Yes,否则No. 分析:先打表求出来一部分素因子,用素数对素数判定还是比较快的. 代码如下: ========================= ...

  2. SGU 113.Nearly prime numbers

    水一个代码: #include <iostream> using namespace std; int n, a; bool ok; bool prime (int x) { ; i * ...

  3. SGU题目总结

    SGU还是个不错的题库...但是貌似水题也挺多的..有些题想出解法但是不想写代码, 就写在这里吧...不排除是我想简单想错了, 假如哪位神犇哪天发现请告诉我.. 101.Domino(2015.12. ...

  4. SGU 分类

    http://acm.sgu.ru/problemset.php?contest=0&volume=1 101 Domino 欧拉路 102 Coprime 枚举/数学方法 103 Traff ...

  5. SGU 495. Kids and Prizes

    水概率....SGU里难得的水题.... 495. Kids and Prizes Time limit per test: 0.5 second(s)Memory limit: 262144 kil ...

  6. NYOJ题目113字符串替换

    aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAr4AAAHvCAIAAAA930vtAAAgAElEQVR4nO3dPVLjysIG4G8T5CyE2A ...

  7. ACM: SGU 101 Domino- 欧拉回路-并查集

    sgu 101 - Domino Time Limit:250MS     Memory Limit:4096KB     64bit IO Format:%I64d & %I64u Desc ...

  8. 【SGU】495. Kids and Prizes

    http://acm.sgu.ru/problem.php?contest=0&problem=495 题意:N个箱子M个人,初始N个箱子都有一个礼物,M个人依次等概率取一个箱子,如果有礼物则 ...

  9. SGU 455 Sequence analysis(Cycle detection,floyd判圈算法)

    题目链接:http://acm.sgu.ru/problem.php?contest=0&problem=455 Due to the slow 'mod' and 'div' operati ...

随机推荐

  1. 金融系列14《QPBOC交易流程》

    中国银行金融IC卡qPBOC交易时间(不含终端处理时间)要求:IC卡私钥长度1024位,交易时间 <= 500ms, 1152 <=600 ATR=3B8D800100814D220886 ...

  2. 6月24日AppCan移动开发者大会礼品清单遭泄露

    6月24日,第一届AppCan移动开发者大会将在北京国际会议中心举办,大会以”平台之上,应用无限”为主题,全景展现移动应用发展趋势.AppCan 移动技术蓝图及80万开发者的技术实践成果. 大会现场礼 ...

  3. WebClient和HttpReuqest两种网络请求的方式

    相对来说webClient请求的方式比较简单,可以直接通过new的方式创建一个实例,然后调用OpenReadAsync方法传进一个url,最后通过回调函数OpenReadCompleted就可以获取网 ...

  4. C#中的委托与事件

    1,委托? 通俗来讲,就是一个能存放符合某种格式(签名)的方法的指针 的容器  (可以将方法作为一个参数来传递到另一个方法内执行) 定义委托:delegate string DelegateSayHi ...

  5. linux系统下sd卡的备份与恢复

    linux系统下sd卡的备份与恢复 现在各种的开发板都是从sd卡上面启动的,因此大修改工作之前很有必要备份一下. 备份 在linux系统下用读卡器读取sd卡 用df -h命令看分区的路径 一般都是/d ...

  6. Web中Listener的创建

    使用Listener只需要两个步骤: 定义Listener实现类. 通过Annotation或在web.xml文件中配置Listener 实现Listener类 监听不同Web事件的监听器不相同,常用 ...

  7. 使用C语言在Win控制台中实现指定位置输出

    在古老的Turbo C中有个GotoXY可以让你在指定坐标中输出文字,可恨的是我看过的C语言书籍,有一半都是关于它的.我现在用着Windows系统,不可能还让我去写着DOS程序啊,起码也得从Win控制 ...

  8. PBOC电子钱包与电子现金及QPBOC

    电子钱包:EP 电子现金:EC,在PBOC规范中的13部分定义了<基于借贷记应用的小额支付规范中> QPBOC:在PBOC规范的12部分中定义了<费接触式IC卡支付规范> PB ...

  9. CS小分队第一阶段冲刺站立会议(5月10日)

    昨日成果:完成了从excel表格导入名单,并且进行抽号的功能 遇到的困难: 1.Excel表格导入时由于版本不同,导致旧版本无法显示,后经修改初步解决 2.改程序无法在未安装office excel驱 ...

  10. C/C++常用头文件及函数汇总

    转自: C/C++常用头文件及函数汇总 C/C++头文件一览 C #include <assert.h> //设定插入点#include <ctype.h> //字符处理#in ...