当前位置:网站首页>L1-028 judging prime number (10 points)
L1-028 judging prime number (10 points)
2022-07-04 07:29:00 【Inter personal liabilities^】
L1-028 Judgement primes (10 branch )
The goal of this question is very simple , Is to determine whether a given positive integer is a prime number .
Input format :
Enter a positive integer on the first line N
(≤ 10), And then N
That's ok , Each line gives a less than 2 31 A positive integer that needs to be judged .
Output format :
For each positive integer to be judged , If it's a prime , Output in one line Yes
, Otherwise output No
.
sample input :
2
11
111
sample output :
Yes
No
Test point 1:231, Must open long long Range ,1 Not primes , This is a special judgment , There is something wrong with this topic ,1 It should be neither prime nor prime
AC Code
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<sstream>
using namespace std;
typedef long long ll;
const int N=100010;
int main()
{
int n;
cin >> n;
while(n -- )
{
ll x;
cin >> x;
bool flag = false;
if(x == 1) flag = true;
for(int i = 2; i < sqrt(x); i ++ )
{
if(x % i == 0)
{
flag = true;
break;
}
}
if(flag) cout << "No" << endl;
else cout << "Yes" << endl;
}
return 0;
}
边栏推荐
- Handwritten easy version flexible JS and source code analysis
- BasicVSR++: Improving Video Super-Resolutionwith Enhanced Propagation and Alignment
- Amd RX 7000 Series graphics card product line exposure: two generations of core and process mix and match
- Zhanrui tankbang | jointly build, cooperate and win-win zhanrui core ecology
- Solution of running crash caused by node error
- The most effective futures trend strategy: futures reverse merchandising
- 电子协会 C语言 1级 35 、银行利息
- Zabbix agent主动模式的实现
- Electronic Association C language level 1 35, bank interest
- How to send mail with Jianmu Ci
猜你喜欢
This monitoring system can monitor the turnover intention and fishing all, and the product page has 404 after the dispute appears
How to send mail with Jianmu Ci
Node foundation ~ node operation
【Kubernetes系列】Kubernetes 上安装 KubeSphere
This article is enough for learning advanced mysql
Distributed transaction management DTM: the little helper behind "buy buy buy"
MySQL中的文本處理函數整理,收藏速查
BasicVSR++: Improving Video Super-Resolutionwith Enhanced Propagation and Alignment
Chain ide -- the infrastructure of the metauniverse
The idea of implementing charts chart view in all swiftui versions (1.0-4.0) was born
随机推荐
博客停更声明
MySQL 数据库 - 函数 约束 多表查询 事务
Introduction to deep learning Ann neural network parameter optimization problem (SGD, momentum, adagrad, rmsprop, Adam)
Basic DOS commands
MYCAT middleware installation and use
Paddleocr prompt error: can not import AVX core while this file exists: xxx\paddle\fluid\core_ avx
Life planning (flag)
tornado之目录
BUUCTF(3)
提升复杂场景三维重建精度 | 基于PaddleSeg分割无人机遥感影像
Splicing plain text into JSON strings - easy language method
电子协会 C语言 1级 35 、银行利息
Implementation of ZABBIX agent active mode
University stage summary
Guoguo took you to write a linked list, and the primary school students said it was good after reading it
Chain ide -- the infrastructure of the metauniverse
Zephyr 學習筆記2,Scheduling
Boast about Devops
User login function: simple but difficult
Computer connects raspberry pie remotely through putty