51 Nod 1106 质数检测
来源:互联网 发布:淘宝店铺营销中心 编辑:程序博客网 时间:2024/06/05 05:04
http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1106
分析:
直接判断是不是素数
AC代码:
#include <iostream>#include <stdlib.h>#include <stdio.h>#include <string.h>#include <math.h>#include <vector>#include <stack>#include <queue>#include <map>#include <set>#include<list>#include <bitset>#include <climits>#include <algorithm>#define gcd(a,b) __gcd(a,b)#define mset(a,n) memset(a,n,sizeof(a))#define FINfreopen("input.txt","r",stdin)#define FOUT freopen("output.txt","w",stdout)typedef long long LL;const LL mod=1e9+7;const int INF=0x3f3f3f3f;const double PI=acos(-1.0);using namespace std;int a[1005];bool prime(int n){ if (n==2) return 1; for (int i=2;i<=(int)sqrt(n);i++){ if (n%i==0) return 0; } return 1;}int main (){ int t; cin>>t; while (t--){ int n; cin>>n; if (prime(n)) cout<<"Yes"<<endl; else cout<<"No"<<endl; } return 0;}
阅读全文
0 0
- 51nod 1106 质数检测
- 51nod 1106 质数检测
- 51nod-1106质数检测
- 51nod 1106 质数检测
- 51nod-【1106 质数检测】
- 51NOD 1106质数检测
- 51Nod 1106 质数检测
- 【51Nod】1106 质数检测
- 51Nod-1106-质数检测
- 51Nod 1106 质数检测
- 51Nod-1106 质数检测
- 51 Nod 1106 质数检测
- 51nod 1106 质数检测
- 【51nod】1106 质数检测
- 51Nod-1106-质数检测
- 【51nod】1106 质数检测 埃拉托斯特尼筛法
- 51nod-1186 质数检测
- 20140915 【 数论 - Miller_Rabin素数测试 】 51nod 1106 . 质数检测
- vueJS的双向绑定原理
- Islands in the Data Stream UVALive
- MySQL ssl连接错误解决
- 使用 maven 构建模块化项目
- 嵌入式学习总体路线
- 51 Nod 1106 质数检测
- Android JobScheduler
- 模板:最大流最小割
- Linux strict_strtoul 函数
- #PL/SQL DEV连接Oracle 弹出空白提示框的解决方案#
- git_快速入门 00 介绍
- C++笔记:select多路复用机制
- Python(1) python外部模块的安装
- 堆和栈相关知识