B. T-primes
/*
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的更多相关文章
- [LeetCode] Count Primes 质数的个数
Description: Count the number of prime numbers less than a non-negative number, n click to show more ...
- 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 ...
- leetcode-Count Primes 以及python的小特性
题目大家都非常熟悉,求小于n的所有素数的个数. 自己写的python 代码老是通不过时间门槛,无奈去看了看大家写的code.下面是我看到的投票最高的code: class Solution: # @p ...
- Count Primes - LeetCode
examination questions Description: Count the number of prime numbers less than a non-negative number ...
- [leetcode] Count Primes
Count Primes Description: Count the number of prime numbers less than a non-negative number, n click ...
- Count Primes
Count the number of prime numbers less than a non-negative number, n public int countPrimes(int n) { ...
- 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 ...
- HDU 4715:Difference Between Primes
Difference Between Primes Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Jav ...
- hdu 4715 Difference Between Primes
题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=4715 Difference Between Primes Description All you kn ...
- hdu 5104 Primes Problem
题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5104 Primes Problem Description Given a number n, ple ...
随机推荐
- @Qualifier注解详解
@Qualifier注解意味着可以在被标注bean的字段上可以自动装配.Qualifier注解可以用来取消Spring不能取消的bean应用. 下面的示例将会在Customer的person属性中自动 ...
- 如何判断SOCKET还是连接着的
转自 http://blog.csdn.net/loadstar_kun/article/details/5790407 1. 用read函数来判断 读到长度0不能断定是已经断开.除非是-1,才代表输 ...
- 如何查看PHP的配置信息
1.问题描述 如何利用PHP函数查看PHP的配置信息 2.问题函数 <?php echo phpinfo(); ?> 3.输出结果 phpinfo() PHP Version => ...
- KAFKA 0.11 RHEL6.5安装
KAFKA简介 KAFKA是一款分布式消息发布和订阅的系统. 官网:http://kafka.apache.org/ 1.下载KAFKA及JDK KAFKA下载地址: http://kafka.apa ...
- awk结合正则匹配
利用awk分析data.csv中label列各取值的分布. 在终端执行head data.csv查看数据: name,business,label,label_name 沧州光松房屋拆迁有限公司,旧房 ...
- IOS开发 ARC和非ARC下使用Block属性的问题
1. Block的声明和线程安全 Block属性的声明,首先需要用copy修饰符,因为只有copy后的Block才会在堆中,栈中的Block的生命周期是和栈绑定的,可以参考之前的文章(iOS: 非AR ...
- Ubuntu16.04 --> 14.04
从16到14 自认为14是比较稳定的.从安装依赖上说. 14安装应用 更多参见[请直接拉到"华丽丽的分割线"下面] Java9 注意,添加源的时候先把lantern打开!!! 添加 ...
- 实战maven私有仓库三部曲之一:搭建和使用
在局域网内搭建maven私有仓库,可避免每次都从中央仓库下载公共jar包,另外将A模块作为二方库发布到私有仓库后,B模块可以很方便的引用,今天我们就来实战maven私有仓库的搭建和使用: 原文地址:h ...
- ThreadDeath 理解
public class RunnableTest2 { public static Object obj1 = new Object(); public static Object obj2 = n ...
- drone 学习三 条件步骤
1. 基本格式 pipeline: slack: image: plugins/slack channel: dev + when: + branch: master 2. 几种条件类型 a. bra ...