B. T-primes
time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

standard output

We know that prime numbers are positive integers that have exactly two distinct positive divisors. Similarly, we'll call a positive integer tТ-prime, if t has exactly three distinct positive divisors.

You are given an array of n positive integers. For each of them determine whether it is Т-prime or not.

Input

The first line contains a single positive integer, n (1 ≤ n ≤ 105), showing how many numbers are in the array. The next line contains nspace-separated integers xi (1 ≤ xi ≤ 1012).

Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is advised to use the cin, cout streams or the %I64dspecifier.

Output

Print n lines: the i-th line should contain "YES" (without the quotes), if number xi is Т-prime, and "NO" (without the quotes), if it isn't.

Examples
input
3
4 5 6
output
YES
NO
NO
Note

The given test has three numbers. The first number 4 has exactly three divisors — 1, 2 and 4, thus the answer for this number is "YES". The second number 5 has two divisors (1 and 5), and the third number 6 has four divisors (1, 2, 3, 6), hence the answer for them is "NO".

猜测 题。一猜  他是平方数  发现16不行  二猜 sqrt(16)应该是素数才行,再看一看诗句范围 正好。

/* ***********************************************
Author :guanjun
Created Time :2016/9/8 17:35:45
File Name :cf142b.cpp
************************************************ */
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue >
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <stdlib.h>
#include <iomanip>
#include <list>
#include <deque>
#include <stack>
#define ull unsigned long long
#define ll long long
#define mod 90001
#define INF 0x3f3f3f3f
#define maxn 100010
#define cle(a) memset(a,0,sizeof(a))
const ull inf = 1LL << ;
const double eps=1e-;
using namespace std;
priority_queue<int,vector<int>,greater<int> >pq;
struct Node{
int x,y;
};
struct cmp{
bool operator()(Node a,Node b){
if(a.x==b.x) return a.y> b.y;
return a.x>b.x;
}
}; bool cmp(int a,int b){
return a>b;
}
ll a[maxn];
bool is(int x){
for(int i=;i*i<=x;i++){
if(x%i==)return false;
}
return true;
}
int main()
{
#ifndef ONLINE_JUDGE
//freopen("in.txt","r",stdin);
#endif
//freopen("out.txt","w",stdout);
int n;
while(cin>>n){
for(int i=;i<=n;i++)cin>>a[i];
for(int i=;i<=n;i++){
if(a[i]==){
puts("NO");continue;
}
ll x=sqrt(a[i]);
if(x*x==a[i]&&is(x)){
puts("YES");
}
else puts("NO");
}
}
return ;
}

Codeforces Round #142 (Div. 2)B. T-primes的更多相关文章

  1. Codeforces Round #142 (Div. 1) C. Triangles

    Codeforces Round #142 (Div. 1) C. Triangles 题目链接 今天校内选拔赛出了这个题,没做出来....自己思维能力还不够强吧.我题也给读错了.. 每次拆掉一条边, ...

  2. Codeforces Round #142 (Div. 2)

    A. Dragons 按\(x\)排序. B. T-primes \(x\)是平方数,且根\(\sqrt{x}\)是个质数. C. Shifts 枚举列的位置,对于每行来说,最多只会涉及4个列. D. ...

  3. Codeforces Round #556 (Div. 2) - C. Prefix Sum Primes(思维)

    Problem  Codeforces Round #556 (Div. 2) - D. Three Religions Time Limit: 1000 mSec Problem Descripti ...

  4. Codeforces Round #556 (Div. 1)

    Codeforces Round #556 (Div. 1) A. Prefix Sum Primes 给你一堆1,2,你可以任意排序,要求你输出的数列的前缀和中质数个数最大. 发现只有\(2\)是偶 ...

  5. Codeforces Round #366 (Div. 2) ABC

    Codeforces Round #366 (Div. 2) A I hate that I love that I hate it水题 #I hate that I love that I hate ...

  6. Codeforces Round #354 (Div. 2) ABCD

    Codeforces Round #354 (Div. 2) Problems     # Name     A Nicholas and Permutation standard input/out ...

  7. Codeforces Round #368 (Div. 2)

    直达–>Codeforces Round #368 (Div. 2) A Brain’s Photos 给你一个NxM的矩阵,一个字母代表一种颜色,如果有”C”,”M”,”Y”三种中任意一种就输 ...

  8. cf之路,1,Codeforces Round #345 (Div. 2)

     cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅.....   ...

  9. Codeforces Round #279 (Div. 2) ABCDE

    Codeforces Round #279 (Div. 2) 做得我都变绿了! Problems     # Name     A Team Olympiad standard input/outpu ...

随机推荐

  1. vim之vimrc配置文件

    """"""""""""""""&quo ...

  2. 07Microsoft SQL Server View

    Microsoft SQL Server View 1.视图 视图是一个虚拟的表,是表中的数据经过某种筛选后的显示方式,视图由预定义的查询select语句组成. 2.查看视图信息 --查询系统所有视图 ...

  3. 【转载】dubbo约束的引入(解决eclipse中报错问题)

    在采用分布式系统架构时,我们会经常使用到阿里巴巴的dubbo的分布式框架. 在相关xml配置了dubbo的约束依赖后,即使能上网eclipse.myeclipse等IDE也是无法识别dubbo的相关约 ...

  4. BLOCK层基本概念:bio,request,request_queue

    Summary bio 代表一个IO 请求 request 是bio 提交给IO调度器产生的数据,一个request 中放着顺序排列的bio 当设备提交bio 给IO调度器时,IO调度器可能会插入bi ...

  5. 简单了解jdbcTemplate的queryForList是如何查询

    queryForList方法会调用query方法,同时会传入一个新的ColumnMapRowMapper对象 ArgumentPreparedStatementSetter对象只有一个Object[] ...

  6. Extjs查询实现

    效果图如上: 页面代码: Ext.QuickTips.init(); //放在图标上会自动提示信息 Ext.define('ExtApp.view.StudentList' , { extend : ...

  7. linux-vmstat-显示虚拟内存状态

    推荐:更多linux 性能监测与优化 关注:linux命令大全 vmstat命令的含义为显示虚拟内存状态(“Viryual Memor Statics”),但是它可以报告关于进程.内存.I/O等系统整 ...

  8. PAT 1123 Is It a Complete AVL Tree

    An AVL tree is a self-balancing binary search tree. In an AVL tree, the heights of the two child sub ...

  9. android保存bitmap到sdcard

    if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) { //判断sdcard是否存在和是否具有读写 ...

  10. Hyper-v交换机添加出错解决方法

    这个问题中文找不到解决方法,只能重新安装系统了 重新安装系统后,按照顺序操作,不要去动设备管理器中的东西,也不用动驱动,先删除虚拟机的网络连接,在删除虚拟交换机就可以了,没有再出现问题