/*
PROBLEMSSUBMITSTATUSSTANDINGSCUSTOM TEST
B. T-primes
time limit per test2 seconds
memory limit per test256 megabytes
inputstandard input
outputstandard 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 n space-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 %I64d specifier. 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. Sample test(s)
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".
*/
#include <iostream>
#include<cmath>
#include<stdio.h>
#include<stdlib.h>
using namespace std;
#define maxn 1003
bool isprime( __int64 n)
{
for( __int64 i=; i<=sqrt((float)n); i++)
if(n%i==)
return ;
return ;
}
int main()
{
__int64 num,n,tmp;
scanf("%I64d",&num);
while(num--) {
scanf("%I64d",&n);
if(n==)
{
printf("NO\n");
continue;
}
tmp=sqrt((float)n);
if(tmp*tmp==n)
{
if(isprime(tmp))
printf("YES\n");
else
printf("NO\n");
}
else
{
printf("NO\n");
}
}
return ;
}

B. T-primes的更多相关文章

  1. [LeetCode] Count Primes 质数的个数

    Description: Count the number of prime numbers less than a non-negative number, n click to show more ...

  2. projecteuler Summation of primes

    The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17. Find the sum of all the primes below two milli ...

  3. leetcode-Count Primes 以及python的小特性

    题目大家都非常熟悉,求小于n的所有素数的个数. 自己写的python 代码老是通不过时间门槛,无奈去看了看大家写的code.下面是我看到的投票最高的code: class Solution: # @p ...

  4. Count Primes - LeetCode

    examination questions Description: Count the number of prime numbers less than a non-negative number ...

  5. [leetcode] Count Primes

    Count Primes Description: Count the number of prime numbers less than a non-negative number, n click ...

  6. Count Primes

    Count the number of prime numbers less than a non-negative number, n public int countPrimes(int n) { ...

  7. hduoj 4715 Difference Between Primes 2013 ACM/ICPC Asia Regional Online —— Warmup

    http://acm.hdu.edu.cn/showproblem.php?pid=4715 Difference Between Primes Time Limit: 2000/1000 MS (J ...

  8. HDU 4715:Difference Between Primes

    Difference Between Primes Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Jav ...

  9. hdu 4715 Difference Between Primes

    题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=4715 Difference Between Primes Description All you kn ...

  10. hdu 5104 Primes Problem

    题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5104 Primes Problem Description Given a number n, ple ...

随机推荐

  1. js的事件循环机制和任务队列

    上篇讲异步的时候,提到了同步队列和异步队列的说法,其实只是一种形象的称呼,分别代表主线程中的任务和任务队列中的任务,那么此篇我们就来详细探讨这两者. 一.来张图感受一下 如果看完觉得一脸懵逼,请继续往 ...

  2. 解析6种常用View 的滑动方法

    View 的滑动是Android 实现自定义控件的基础,实现View 滑动有很多种方法,在这里主要讲解6 种滑动方法,分别是layout().offsetLeftAndRight()与offsetTo ...

  3. 《Tomcat内核设计剖析》勘误表

    <Tomcat内核设计剖析>勘误表 书中第95页图request部分印成了reqiest. 书中第311页两个tomcat3,其中一个应为tomcat4. 书中第5页URL应为URI. 书 ...

  4. ET之快递测试法学习感悟20140922

    快递测试法,是从ET学习中了解到的一种测试方法,顾名思义就是数据类似于那些通过联邦快递系统在这个星球上被不断移动的包裹一样,在软件中也不断的流动.数据从被输入后就开始了它的生命周期,先被存储在内部变量 ...

  5. java入门学习(3)—循环,选择,基础算法,API概念

    1.顺序结构:也就是顺着程序的前后关系,依次执行.2.选择分支:利用if..else , / switch(){case [ 这个必须是常量]:}; / if..else if….. ….else.. ...

  6. 安装Oracle 11G Enterprise Manager工具

    1.登录ORACLE数据库 sqlplus / as sysdba; 2.查询实例名 SQL> select instance_name from v$instance; INSTANCE_NA ...

  7. 跳转后全屏,兼容大部分浏览器JavaScript

    <!DOCTYPE html> <html> <head> <title>测试</title> </head> <body ...

  8. BZOJ - 3295 动态逆序对 (树状数组套treap)

    题目链接 思路和bzoj2141差不多,不过这道题的数据更强一些,线段树套treapT了,树状数组套treap卡过~~ #include<bits/stdc++.h> using name ...

  9. ubnut16.4 下 设置静态ip

    一.编辑interfaces sudo vi /etc/network/interface ### i 键进入编辑 二.编辑该文件 auto loiface lo inet loopbackauto ...

  10. flask第十五篇——Response

    从这一节开始,我就要开始讲关于模板的知识了.先来学习一下Response的相关知识. 所有返回前台的内容其实都应该是Response的对象或者其子类,我们看到如果返回的是字符串直接可以写成return ...