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. 06Microsoft SQL Server 完整性约束

    Microsoft SQL Server 完整性约束 标识 IDENTITY自动编号 CREATE TABLE table_name( id ,), NAME ) not null, sex ) de ...

  2. iOS APP EuclidStudy Service Support

    Hi,If you have any questions, you can send a message here or send them to us. We will answer you as ...

  3. (转载)不错的CSS写法

    根据微信订阅号“设计达人”推送的文章,学到了如题知识.个人尝试了一下,感觉还不错.原文链接:http://mp.weixin.qq.com/s/g9TyBwB9xIi45TGwTBOLSQ. 字体 从 ...

  4. IP地址、MAC地址、ARP地址解析协议

    互联网中一台主机要和另一台主机实现通信首先需要知道彼此在互联网中的位置,主机在互联网中的位置是通过ip地址标记的,当找到ip地址后,再通过端口号标识运行在主机中的进程从而实现通信. IP地址: IP地 ...

  5. <MyBatis>入门五 查询的返回值处理

    select : 返回对象:  <select  id = " "  resultType= "对象的全类名"  /> List: <sele ...

  6. NFV

    转载: NFV介绍定义:NFV,即网络功能虚拟化,Network Function Virtualization.通过使用x86等通用性硬件以及虚拟化技术,来承载很多功能的软件处理.从而降低网络昂贵的 ...

  7. PKI相关知识简述

    1. 公钥泄露导致中间人攻击 有A.B.C三个人,如果C把自己的公钥提供给了AB双方,C伪装成B,让A认为C就B,这样A就把自己的公钥发送给C,C再伪装成A,让B认为C就A,B就把自己的公钥也发送给了 ...

  8. sectional data interpolation in Tecplot

    $!Varset |NumLoop|= $!Loop |NumLoop| $!Varset |num|=(|Loop|*+) $!RotateData ZoneList = [] Angle = |n ...

  9. C,LINUX,数据结构部分

    1604期 第1期测试(面试精选:C,LINUX,数据结构部分) 本试卷从考试酷examcoo网站导出,文件格式为mht,请用WORD/WPS打开,并另存为doc/docx格式后再使用 试卷编号:24 ...

  10. Java MyBatis 插入数据库返回主键--insertSelective这样就不用每次到数据库里面查询了

    insertSelective---Java MyBatis 插入数据库返回主键--insertSelective这样就不用每次到数据库里面查询了 https://www.cnblogs.com/xi ...