# DIV. 2 B — T-PRIMES

http://www.yyycode.cn/index.php/2020/05/23/div-2-b-t-primes/

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 x i (1 ≤ x i ≤ 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 x i is Т-prime, and “NO” (without the quotes), if it isn’t.ExamplesinputCopy

3
4 5 6


outputCopy

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<vector>
#include<queue>
#include<cstring>
#include<algorithm>
using namespace std;
const int maxn=1e5+10;
typedef long long LL;
LL a[maxn];
int main(void)
{
cin.tie(nullptr);std::ios::sync_with_stdio(false);
LL n;cin>>n;
LL k;
for(LL i=1;i<=n;i++)
{
LL flag=1;
cin>>k;
////x的范围是1e12,这个复杂度是sqrt(n)的 ,转化
LL c=sqrt(k);
if(c*c!=k||k==1)
{
cout<<"NO\n";continue;
}

for(LL j=2;j<=c/j;j++)
{
if(c%j==0)
{
flag=0;cout<<"NO\n";break;
}
}
if(flag) cout<<"YES\n";
}
return 0;
}



LL t=sqrt(n);
for(LL i=2;i<=t;i++)

#include<iostream>
#include<vector>
#include<queue>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
const int maxn=1e5+10;
typedef long long LL;
bool prime(LL n)
{
LL t=sqrt(n);
for(LL i=2;i<=t;i++)
{
if(n%i==0)
return 0;
}
return 1;
}

int main(void)
{
cin.tie(nullptr);std::ios::sync_with_stdio(false);
LL n;
LL k;
cin>>n;
for(LL i=1;i<=n;i++)
{
cin>>k;
////x的范围是1e12,这个复杂度是sqrt(n)的 ,转化
LL c=sqrt(k);
if(c*c>=k&&k!=1&&prime(c))
{
cout<<"YES\n";
}
else cout<<"NO\n";
}
return 0;
}



04-03 596

03-05 71

03-05 65

08-17 435

09-30 112

04-30 107

09-08 9

09-30 95

09-30 150

03-05 1631

09-30 28

04-09 13

05-31 75

05-03 125

08-11 269

03-05 236

02-23 12

03-06 138

10-02 35

04-14 58万+

03-13 14万+

03-04 13万+

03-05 5670

03-08 4万+

03-08 7万+

03-10 12万+

03-12 11万+

03-13 11万+

03-14 9947

03-18 5407

03-18 8639

03-19 3万+

03-19 8万+

03-20 7413

03-24 3万+

03-25 3万+

05-08 5万+

03-25 9万+

03-29 21万+

03-29 1万+

03-29 10万+

03-30 16万+

05-28 5112

05-28 1万+

04-02 4万+

04-03 3057

04-06 7万+

04-07 5万+

04-09 8万+

04-09 2万+

05-17 7369

04-10 2461

04-11 3万+

04-15 5万+

04-18 4万+

04-20 4万+

04-24 3万+

04-29 5796

04-29 5578

04-30 4565

04-30 8810

04-30 8304

05-16 5万+

05-08 4万+

05-11 3万+

05-12 1万+

05-13 414

05-14 5606

05-14 1469

05-16 1万+

05-20 488

05-18 7609

05-27 502

05-18 2922

05-19 9757

05-21 5560

05-21 5568

05-25 3279

05-22 151

#### 计算机网络（谢希仁）— 第一章-计算机网络概述【一】

©️2019 CSDN 皮肤主题: 技术工厂 设计师: CSDN官方博客