JDOJ 1152 是否是素数
2024-08-26 13:46:01
1152: 是否是素数
https://neooj.com:8082/oldoj/problem.php?id=1152
题目描述
写一个判断素数的函数,在主函数输入一个整数,输出是否是素数的消息。
输入
一个数
输出
如果是素数输出prime 如果不是输出not prime
样例输入
97
样例输出
prime
判素数是很常用的技巧,尤其是后面学到数论之后会对一些知识点起到启发性作用。
AC CODE:
#include<cstdio>
#include<cmath>
#include<cstring>
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int prime(int x)
{
for(int i=;i<=sqrt(x);i++)
if(x%i==)
return ;
return ;
}
int main()
{
int n,hahaha;
scanf("%d",&n);
hahaha = prime(n);
if(hahaha==)
printf("not prime");
else
printf("prime");
return ;
}
最新文章
- sql 删除表中的重复记录
- delete
- NOIP主要考查范围
- asp.net中当点击按钮时出现grid编辑弹框
- win7(X64)系统下cuda7.5和VS2013的配置
- ASP.NET的SEO:基础知识
- opensuse 安装 Anaconda3 之后出现Could not start d-bus. Can you call qdbus?
- SQL SERVER安装提示“安装了 Microsoft Visual Studio 2008 的早期版本
- hadoop数据流转过程分析
- Swift - 41 - swift1.2新特性(1)
- Ruby入门--Linux/Windows下的安装、代码开发及Rails实战
- STM32F407的串口采用DMA收发数据
- apache用户认证,ssl双向认证配置
- python入门之函数
- ftp服务器的简单配置使用
- php中heredoc与nowdoc的使用方法
- tomcat 修改默认字符集
- Angular 自定义拖拽指令
- 页面中dropDownListt的二级关联
- Web常见安全漏洞-SQL注入
热门文章
- FFT_应用和例题
- vue.js 使用v-model v-once
- Win10中SVN图标不显示的解决
- Paper | Dynamic Residual Dense Network for Image Denoising
- 【SpringCloud之pigx框架学习之路 】2.部署环境
- Python连载34-信息队列
- HTML+css基础 css的几种形式
- Practical Go: Real world advice for writing maintainable Go programs
- webstorm关闭烦人的eslint语法检查
- NoNodeAvailableException[None of the configured nodes are available:[.127.0.0.1}{127.0.0.1:9300]