SGU 113.Nearly prime numbers
水一个代码:
#include <iostream>
using namespace std;
int n, a; bool ok;
bool prime (int x) {
for (int i = ; i * i <= x; i++) if (x % i == ) return false;
return true;
}
int main() {
cin >> n;
while (n--) {
cin >> a;
ok = false;
for (int i = ; i * i <= a; i++)
if (a % i == )
if (prime (a / i) ) {
ok = true;
break;
}
else break;
if (ok) cout << "Yes" << endl;
else cout << "No" << endl;
}
return ;
}
SGU 113.Nearly prime numbers的更多相关文章
- SGU 113
113. Nearly prime numbers time limit per test: 0.25 sec. memory limit per test: 4096 KB Nearly prime ...
- 快速切题 sgu113 Nearly prime numbers 难度:0
113. Nearly prime numbers time limit per test: 0.25 sec. memory limit per test: 4096 KB Nearly prime ...
- POJ 2739. Sum of Consecutive Prime Numbers
Sum of Consecutive Prime Numbers Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 20050 ...
- POJ 2739 Sum of Consecutive Prime Numbers(尺取法)
题目链接: 传送门 Sum of Consecutive Prime Numbers Time Limit: 1000MS Memory Limit: 65536K Description S ...
- algorithm@ Sieve of Eratosthenes (素数筛选算法) & Related Problem (Return two prime numbers )
Sieve of Eratosthenes (素数筛选算法) Given a number n, print all primes smaller than or equal to n. It is ...
- HDOJ(HDU) 2138 How many prime numbers(素数-快速筛选没用上、)
Problem Description Give you a lot of positive integers, just to find out how many prime numbers the ...
- Codeforces 385C Bear and Prime Numbers
题目链接:Codeforces 385C Bear and Prime Numbers 这题告诉我仅仅有询问没有更新通常是不用线段树的.或者说还有比线段树更简单的方法. 用一个sum数组记录前n项和, ...
- POJ2739 Sum of Consecutive Prime Numbers(尺取法)
POJ2739 Sum of Consecutive Prime Numbers 题目大意:给出一个整数,如果有一段连续的素数之和等于该数,即满足要求,求出这种连续的素数的个数 水题:艾氏筛法打表+尺 ...
- Alexandra and Prime Numbers(思维)
Alexandra and Prime Numbers Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (J ...
随机推荐
- ServiceStack.Redis常用操作 - 事务、并发锁
一.事务 使用IRedisClient执行事务示例: using (IRedisClient RClient = prcm.GetClient()) { RClient.Add("key&q ...
- Spark SQL inferSchema实现原理探微(Python)
使用Spark SQL的基础是“注册”(Register)若干表,表的一个重要组成部分就是模式,Spark SQL提供两种选项供用户选择: (1)applySchema applySche ...
- 每天进步一点点--JS中的getYear()
又是这两天在项目中遇到的,或许很简单,但真实第一次遇到,记录一下. 在页面上用JS获取了一下当前的日期,并用getYear()方法返回了当前的年度,2013也没问题,代码在IE中都测试通过了之后就提交 ...
- 曾经的岁月之maya
- Tree2cycle
Problem Description A tree with N nodes and N-1 edges is given. To connect or disconnect one edge, w ...
- HDOJ/HDU 1062 Text Reverse(字符串翻转~)
Problem Description Ignatius likes to write words in reverse way. Given a single line of text which ...
- A*寻路算法的探寻与改良(一)
A*寻路算法的探寻与改良(一) by:田宇轩 第一部分:这里我们主 ...
- angularjs post 跨域
web api搞好了:用Ajax妥妥的:但是前端用的AngulagJS,也懒得再换为Ajax了: 但是问题来了:提示: 已拦截跨源请求:同源策略禁止读取位于 http://x.x.x.x:port/a ...
- libcurl 使用的几个注意事项
注:libcurl 入门指南( the tutorial ): http://curl.haxx.se/libcurl/c/libcurl-tutorial.html 0. 为使用的curl url ...
- 微软ASP.NET网站部署指南(10):迁移至SQL Server
1. 综述 第2章的部署SQL Server Compact和第9章的部署数据库更新里解释了为什么终于要升级到完整版SQL Server .本章节将告诉你怎样来做. SQL Server Expre ...