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. NOJ1066-堆排序

    堆排序 时间限制(普通/Java) : 1000 MS/ 3000 MS          运行内存限制 : 65536 KByte总提交 : 414            测试通过 : 220  比 ...

  2. word超链接显示HYPERLINK

    在word中编辑超链接后显示的并不是正常的超链接 正常的超连接 非正常显示 解决办法: 文件---选项----高级,如下图 将“显示域代码而非值域”前面的勾去掉.

  3. 动态切换采用 CSplitterWnd 静态划分的视图布局(MFC)

    标题读起来有些拗口,具体是什么情况,我们来看: 一.问题的提出 一个采用MFC开发的软件,其窗体视图采用CSplitterWnd三分,效果如下图所示: 图1 软件的默认视图布局 该MFC开发的软件功能 ...

  4. hdu 5311 Hidden String

    题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5311 Hidden String Description Today is the 1st anniv ...

  5. Android 上下文菜单实现

    1.覆盖Activity的onCreateContenxtMenu()方法,调用Menu的add方法添加菜单项(MenuItem). 2.覆盖Activity的onContextItemSelecte ...

  6. Go循环引用问题

    在Go中,不支持循环引用,即package a引用了packageb以后,package b就不能引用package a了. 最简单的场景: package a中定义context.go用来保存上下文 ...

  7. python 生成二维码

    #coding:utf8 try: import qrcode except ImportError: qrcode = None class MakeQr: def onUseQrcode(self ...

  8. Timer Design in StatusBar

    Timer in StatusBar we need to show local time in StatusBar. solution: 1. add textblock control 2. bi ...

  9. EntityFramework.Extended扩展用法

    EntityFramework.Extended是一个基于EntityFramework框架 IQueryable类型的扩展方法,包括Update.Delete. 它的优点就是 修改删除操作不仅仅有I ...

  10. KinectStudio使用教程

    在Kinect SDK 2.0安装结束之后,会有一个KinectStudio的调试工具,他可以将动作记录下,以后即便脱离了Kinect传感器也可以愉快的调试了.现在我们来看看如何使用 首先打开Kine ...