题目链接:Problem - 7129

Problem Description

A positive integer is called a prime if it is greater than 1 and cannot be written as the product of two smaller positive integers. A primality test is an algorithm for determining whether an input number is a prime. For example, the Miller-Rabin primality test is a probabilistic primality test. This problem is precisely the one about the primality test.

Let's define the function f(x) as the smallest prime which is strictly larger than x. For example, f(1)=2, f(2)=3, and f(3)=f(4)=5. And we use ⌊x⌋ to indicate the largest integer that does not exceed x.

Now given x, please determine whether g(x) is a prime.

g(x)=⌊f(x)+f(f(x))2⌋

Input

The first line of the input contains an integer T (1≤T≤105), indicating the number of test cases.

Each test case contains an integer x (1≤x≤1018) in a single line.

Output

For each test case, if g(x) is a prime, output YES in a single line. Otherwise, output NO in a single line.

Sample Input


2

1

2

Sample Output


YES

NO

题意:f(x) = 大于x的最小素数

然后判断g(x)是否为素数

思路:只有x==1的时候g(x)= 2 为素数

#include<bits/stdc++.h>
using namespace std;int main(){int t;cin >> t;while(t--){long long n;cin >> n;if(n == 1){cout << "YES" << endl;}else{cout << "NO" << endl;}}return 0;
} 

Primality Test HDU7129相关推荐

  1. 米勒罗宾素性测试(Miller–Rabin primality test)

    1 #include<iostream> //该程序为哥德巴赫猜(想输出所有的组合) 2 #include<cmath> 3 #include<cstdlib> 4 ...

  2. Primality Test 素数,打表

    题意 :f(x)f(x)f(x)是严格大于x的最小质数,g(x)=[f(x)+f(f(x))]/2g(x)=[f(x)+f(f(x))]/2g(x)=[f(x)+f(f(x))]/2的向下取整,判断g ...

  3. 用 js判断 一个数是否是素数(质数)_2020-09-20:如何判断一个数是质数?

    福哥答案2020-09-20:#福大大架构师每日一题# 1.试除法.朴素素数筛,埃氏筛,欧拉筛和区间筛.代码采用朴素素数筛. 2.费尔马素性测试法法.费马小定理:假如p是质数,a是整数,且a.p互质, ...

  4. 初等数论--同余--MILLER-RABIN素性检测算法优化

    初等数论--同余--MILLER-RABIN素性检测算法优化 Euler theorem.Fermat's little theorem Primality Test: Fermat.MILLER-R ...

  5. 费马素性测试和米勒—拉宾素性测试

    chapter 1 Fermat's little theorem 费马小定理 费马小定理说的是:如果p是一个素数,那么对于任意一个整数a,a p − a 能被p整除,也可以用模运算表示如下: (p是 ...

  6. 计算机常用编程英语词汇大全,计算机编程及常用术语英语词汇大全

    第一部分.计算机算法常用术语中英对照 Data Structures 基本数据结构 Dictionaries 字典 Priority Queues 堆 Graph Data Structures 图 ...

  7. HDU 4548 美素数 素数题解

    本题就是能够直接打表的,推断能否够打表也须要技巧的: 1 推断最大的数值为1000000.百万下面的数打表都是能够的 2 能够线性预处理好.使用素数筛子法是能够接近线性预处理的. 故此能够打表了. 须 ...

  8. fermat数推素数无穷_如何在3分钟内对Fermat测试进行素数测试

    fermat数推素数无穷 The Fermat test is based on a result from number theory known as Fermat's little theore ...

  9. c语言专属英语单词,C语言 V 编程英语单词.doc

    编程词汇英汉对照 Data Structures 基本数据结构 Dictionaries 字典 Priority Queues 堆 Graph Data Structures 图 Set Data S ...

最新文章

  1. hdu 5273 Dylans loves sequence 逆序数简单递推
  2. Java学习之Hello World 第一个小程序
  3. Python文件格式 .py .pyc .pyw .pyo .pyd的主要区别
  4. cocos2d基础介绍
  5. Linux系统编程8-18总结项目:完成一个简单的自己的shell
  6. mysql临时关闭查询日志_mysql故障排错临时打开通用日志和慢查询日志
  7. python播放音乐-python 模拟(简易)音乐播放器
  8. MongoDB C Driver使用教程
  9. AcWing提高算法课Level-3 第六章 基础算法
  10. SuperWebSocket发布0.1版本
  11. NIO+SocketChannel+Buffer+Selector 多路复用
  12. 安卓移动端appium环境搭建流程
  13. Terminating app due to uncaught exception ‘NSInvalidArgumentException‘
  14. linux基础的基础命令操作
  15. 吴恩达机器学习课程笔记(英文授课) Lv.1 新手村(回归)
  16. JSF 原理简要介绍
  17. vue 项目中使 实现粒子动态 背景图
  18. 使用百度云主机的GPU主机教程_第二部分
  19. mysql如何设置密码
  20. 百度贴吧测试部门实习生电话面试

热门文章

  1. 薅羊毛——我的最爱 常用的书籍羊毛大全
  2. 《越狱》第一季 第1集
  3. 【Latex】插入中文
  4. 7年赚的2个亿,数学家6年就花光了,全砸在自家的房子上
  5. 不惧掉签 | 苹果IPA安装包,免费自签教程
  6. linux 卸载glibc,CentOS下glibc库卸载恢复
  7. docker 入门 —— docker容器数据卷volumes-from
  8. 如何监控电动车充电桩能耗?
  9. 第七版(谢希仁)计算机网络知识点总结
  10. 正点原子T100智能焊台-试用-拆机测评