当前位置:网站首页>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;
}
边栏推荐
- 在所有SwiftUI版本(1.0-4.0)中原生实现Charts图表视图之思路
- [C language] open the door of C
- BUUCTF(4)
- Deep profile data leakage prevention scheme
- Why does the producer / consumer mode wait () use while instead of if (clear and understandable)
- Flink memory model, network buffer, memory tuning, troubleshooting
- MySQL 数据库 - 函数 约束 多表查询 事务
- MySQL error resolution - error 1261 (01000): row 1 doesn't contain data for all columns
- Blog stop statement
- Unity 从Inspector界面打开资源管理器选择并记录文件路径
猜你喜欢

神经网络入门(下)

Rhcsa day 3

The most effective futures trend strategy: futures reverse merchandising

Practice (9-12 Lectures)

用于压缩视频感知增强的多目标网络自适应时空融合

Splicing plain text into JSON strings - easy language method

com. alibaba. nacos. api. exception. NacosException

Detailed introduction to the big changes of Xcode 14

Unity opens the explorer from the inspector interface, selects and records the file path

tornado项目之路由装饰器
随机推荐
Chapter 1 programming problems
In the era of low code development, is it still needed?
How does dataframe calculate the average value of each row as another column
电子协会 C语言 1级 35 、银行利息
BUUCTF(3)
[web security] nodejs prototype chain pollution analysis
Paddleocr prompt error: can not import AVX core while this file exists: xxx\paddle\fluid\core_ avx
Literature collation and thesis reading methods
Docker install MySQL
【森城市】GIS数据漫谈(一)
The idea of implementing charts chart view in all swiftui versions (1.0-4.0) was born
Valentine's Day is coming! Without 50W bride price, my girlfriend was forcibly dragged away...
Chain ide -- the infrastructure of the metauniverse
2022-021ARTS:下半年開始
There is no Chinese prompt below when inputting text in win10 Microsoft Pinyin input method
Adaptive spatiotemporal fusion of multi-target networks for compressed video perception enhancement
MySQL中的文本處理函數整理,收藏速查
Detailed introduction to the big changes of Xcode 14
Introduction to deep learning Ann neural network parameter optimization problem (SGD, momentum, adagrad, rmsprop, Adam)
[Android reverse] function interception (use cache_flush system function to refresh CPU cache | refresh CPU cache disadvantages | recommended time for function interception)