Codeforces Round #142 (Div. 2)B. T-primes
2 seconds
256 megabytes
standard input
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.
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.
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.
3
4 5 6
YES
NO
NO
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的更多相关文章
- Codeforces Round #142 (Div. 1) C. Triangles
Codeforces Round #142 (Div. 1) C. Triangles 题目链接 今天校内选拔赛出了这个题,没做出来....自己思维能力还不够强吧.我题也给读错了.. 每次拆掉一条边, ...
- Codeforces Round #142 (Div. 2)
A. Dragons 按\(x\)排序. B. T-primes \(x\)是平方数,且根\(\sqrt{x}\)是个质数. C. Shifts 枚举列的位置,对于每行来说,最多只会涉及4个列. D. ...
- Codeforces Round #556 (Div. 2) - C. Prefix Sum Primes(思维)
Problem Codeforces Round #556 (Div. 2) - D. Three Religions Time Limit: 1000 mSec Problem Descripti ...
- Codeforces Round #556 (Div. 1)
Codeforces Round #556 (Div. 1) A. Prefix Sum Primes 给你一堆1,2,你可以任意排序,要求你输出的数列的前缀和中质数个数最大. 发现只有\(2\)是偶 ...
- 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 ...
- Codeforces Round #354 (Div. 2) ABCD
Codeforces Round #354 (Div. 2) Problems # Name A Nicholas and Permutation standard input/out ...
- Codeforces Round #368 (Div. 2)
直达–>Codeforces Round #368 (Div. 2) A Brain’s Photos 给你一个NxM的矩阵,一个字母代表一种颜色,如果有”C”,”M”,”Y”三种中任意一种就输 ...
- cf之路,1,Codeforces Round #345 (Div. 2)
cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅..... ...
- Codeforces Round #279 (Div. 2) ABCDE
Codeforces Round #279 (Div. 2) 做得我都变绿了! Problems # Name A Team Olympiad standard input/outpu ...
随机推荐
- dom4j使用方法详解
本文先做知识点的简单介绍,最后附完整案例. 一.解析XML文件 public class Foo { //url为XML文档地址 //自己封装了一个工具类 返回解析完成的document public ...
- 校内测之zay与银临 (day2)(只有T1)
一些与题目无关的碎碎念 推出式子来一定要化简!!!freopen不要写错!!!特判不要瞎搞!!!! 做到以上三点能高35分qwq T1 江城唱晚 你看数据那么大,显然又是一道数学题. 这里有n个种海棠 ...
- 如何使用Dilworth定理
相关例题:NOIP 1999导弹拦截 遇到这题不会去网上搜Dilworth定理,太难受了,看不懂证明 但是,我知道怎么使用了,管那么多,会用就完事了 学习自这篇文章 -1.为什么我不想学证明这个定理 ...
- MySQL数据导入sql文件过程中出错
错误类型: ERROR 1231 (42000): Variable 'time_zone' can't be set to the value of 'NULL' ERROR 1231 (42000 ...
- Linux学习笔记记录(二)
- Linux学习笔记(七) 查询系统
1.查看命令 (1)man 可以使用 man 命令名称 命令查看某个命令的详细用法,其显示的内容如下: NAME:命令名称 SYNOPSIS:语法 DESCRIPTION:说明 OPTIONS:选项 ...
- 关于图片预览使用base64在chrome上的性能问题解决方法
在开发后台上传图片的功能时候使用base64预览图片,结果在传入大量图片后导致chrome崩溃,代码如下 var img = new Image(); var render = new FileRea ...
- 介绍一个比较酷东西:HTML5 桌面通知(Notification API)
Notification API 是 HTML5 新增的桌面通知 API,用于向用户显示通知信息.该通知是脱离浏览器的,即使用户没有停留在当前标签页,甚至最小化了浏览器,该通知信息也一样会置顶显示出来 ...
- 洛谷 2476 [SCOI2008]着色方案
50%的数据满足:1 <= k <= 5, 1 <= ci <= 3 100%的数据满足:1 <= k <= 15, 1 <= ci <= 5 [题解] ...
- hadoop balancer 二
1.每次迭代一个datanode会移动不超过如下两者中较小的一个的数据量 1)10G 2)能力阈值 dfs.datanode.balance.bandwidthPerSec 每次迭代时间不会超过20分 ...