当前位置:网站首页>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;
}
边栏推荐
- 2022-021rts: from the second half of the year
- One of the general document service practice series
- Go learning notes - constants
- Recursive Fusion and Deformable Spatiotemporal Attention for Video Compression Artifact Reduction
- NLP-文献阅读总结
- Deep profile data leakage prevention scheme
- Amd RX 7000 Series graphics card product line exposure: two generations of core and process mix and match
- Why does the producer / consumer mode wait () use while instead of if (clear and understandable)
- [MySQL transaction]
- Practice (9-12 Lectures)
猜你喜欢
节点基础~节点操作
[Android reverse] function interception (use cache_flush system function to refresh CPU cache | refresh CPU cache disadvantages | recommended time for function interception)
深入浅出:了解时序数据库 InfluxDB
Comparison between applet framework and platform compilation
Crawler (III) crawling house prices in Tianjin
Zephyr 學習筆記2,Scheduling
The IP bound to the socket is inaddr_ The meaning of any htonl (inaddr_any) (0.0.0.0 all addresses, uncertain addresses, arbitrary addresses)
L2-013 red alarm (C language) and relevant knowledge of parallel search
MySQL storage engine
Vulhub vulnerability recurrence 77_ zabbix
随机推荐
MySQL中的文本處理函數整理,收藏速查
Node foundation ~ node operation
kubernetes集群之Label管理
【FreeRTOS】FreeRTOS学习笔记(7)— 手写FreeRTOS双向链表/源码分析
Label management of kubernetes cluster
Distributed transaction management DTM: the little helper behind "buy buy buy"
Detailed introduction to the big changes of Xcode 14
How to send mail with Jianmu Ci
[freertos] freertos Learning notes (7) - written freertos bidirectionnel Link LIST / source analysis
"Sword finger offer" 2nd Edition - force button brush question
输入年份、月份,确定天数
window上用.bat文件启动项目
Deep profile data leakage prevention scheme
Rhcsa the next day
Zephyr learning notes 1, threads
The number of patent applications in China has again surpassed that of the United States and Japan, ranking first in the world for 11 consecutive years
A real penetration test
This monitoring system can monitor the turnover intention and fishing all, and the product page has 404 after the dispute appears
大学阶段总结
电子协会 C语言 1级 34 、分段函数