/*
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. Eclipse上安装springsource-tool-suite

    spring tool suite 是一个基于eclipseIDE开发环境中的用于开发spring应用程序的工具.提供了开箱即用的环境用于实现,调试和部署你的spring应用,包括为关键的的服务器和云 ...

  2. 收集hive优化解决方案

    hive的优化问题1.启动一次JOB尽可能多做事,尽量减少job的数量.能重用就重用,要设计好的模型.2.合理设置reduce个数,reduce个数过多,会造成大量小文件问题.3.使用hive.exe ...

  3. sql server不能删除数据库,显示错误:正在使用

    解决办法: use mastergoalter database database_name set single_user with rollback immediate --将数据库回滚到原始配置 ...

  4. OK335xS 系统启动配置解析

    OK335xS 系统启动配置解析 一.参考文档: AM335x ARM® Cortex™-A8 Microprocessors (MPUs) Technical Reference Manual 二. ...

  5. [剑指offer]数组中最小的K个数,C++实现

    原创博文,转载请注明出处! http://github.com/wanglei5205 http://cnblogs.com/wanglei5205 # 题目 输入n个整数,找出其中最小的K个数.例如 ...

  6. Jenkins构建持续集成

    Jenkins 是一个开源软件项目,旨在提供一个开放易用的软件平台,使软件的持续集成变得可能.现在软件开发追求的是效率以及质量,Jenkins使得自动化成为可能! 亮点 采用shell自定义脚本,控制 ...

  7. sersync2 文件的实时同步备份

    |——需求: 监控192.168.9.5[主]  下的 /data/vmeipai 目录  --> 同步到 192.168.12.8 [备] 下的 /data/vmeipai 目录 |——网络拓 ...

  8. C++调用SQLServer存储过程

    同事手头的C++工程中涉及SQLServer数据库的操作需要优化,说是测试调用存储过程失败,提示: 要了C++的源码: 折腾半天,最终定位问题,问题不在C++的代码,而是SQLServer的存储过程要 ...

  9. JS格式化数字(每三位加逗号)

    function toThousands(num) { var num = (num || 0).toString(), result = ''; //判断是否带小数点 if (num.split(' ...

  10. JS 区分单击双击

    var timeout =null; $("#Btn").on("click",function(){ clearTimeout(timeout);//停止单击 ...