SCUT Training 20170913 Problem I
来源:互联网 发布:西安行知教育地址 编辑:程序博客网 时间:2024/06/13 13:26
原题:http://acm.hdu.edu.cn/showproblem.php?pid=2161
思路:
判断质数而已,注意2在这题是不算质数的。
源代码:
#include <iostream>#include <cmath>using namespace std;int counter=0;int n,lim;bool out=false;int main(){ while (cin>>n && n>0) { out=false; counter++; if (n==1 || n==2) { cout<<counter<<": no"<<endl; } else { lim=sqrt(n); for (int i = 2;i<=lim;i++) if (n%i==0) { cout << counter << ": no" << endl; out=true; break; } if (out==false) cout<<counter<<": yes"<<endl; } }}
阅读全文
0 0
- SCUT Training 20170913 Problem I
- SCUT Training 20170920 Problem I
- SCUT Training 20170913 Problem A
- SCUT Training 20170913 Problem B
- SCUT Training 20170913 Problem C
- SCUT Training 20170913 Problem D
- SCUT Training 20170913 Problem E
- SCUT Training 20170913 Problem F
- SCUT Training 20170913 Problem G
- SCUT Training 20170913 Problem H
- SCUT Training 20170913 Problem J
- SCUT Training 20170913 Problem K
- SCUT Training 20170913 Problem L
- SCUT Training 20170913 Problem M
- SCUT Training 20170913 Problem N
- SCUT Training 20170913 Problem O
- SCUT Training 20170913 Problem P
- SCUT Training 20170920 Problem A
- SQL 2008安装图解
- Mybatis 一对一,一对多,多对一,多对多的理解
- 堆排序
- log 的 debug()、 error()、 info()方法的区别
- C和C++中的名字空间和作用域
- SCUT Training 20170913 Problem I
- Django操作数据库
- Android新特性介绍,ConstraintLayout完全解析
- 素数筛实现素数的快速筛选
- 梯度下降-Momentum
- AS3.0 迁移解决方案 apk命名打包异常
- C++ const
- web居中布局-水平居中
- 《C专家编程》1-2章阅读收获