题目描述 Description

给定2个整数a,b 求出它们之间(不含a,b)所有质数的和。

输入描述 Input Description

一行,a b(0<=a,b<=65536)

输出描述 Output Description

一行,a,b之间(不含a,b)所有素数的和。

样例输入 Sample Input

39 1224

样例输出 Sample Output

111390

数据范围及提示 Data Size & Hint

注意没有要求a<b

 #include <algorithm>
#include <iostream>
#include <cstdio> using namespace std; int a,b,ans; bool judge(int x)
{
for(int i=;i*i<=x;i++)
if(x%i==) return ;
return ;
} int main()
{
scanf("%d%d",&a,&b);
int aa=min(a,b),bb=max(a,b);
for(int i=aa+;i<bb;i++)
if(judge(i))
ans+=i;
printf("%d",ans);
return ;
}

T1462 素数和 codevs的更多相关文章

  1. 素数筛 codevs 1675 大质数 2

    1675 大质数 2  时间限制: 1 s  空间限制: 1000 KB  题目等级 : 钻石 Diamond 题解  查看运行结果     题目描述 Description 小明因为没做作业而被数学 ...

  2. 【数论】【筛法求素数】CODEVS 1462 素数和

    好吧……我不会欧拉筛也就罢了…… 傻逼筛法竟然这么长时间以来 一直RE ……源头竟然是 int 爆了. #include<cstdio> #include<algorithm> ...

  3. codevs 2964 公共素数因数

    提交地址:http://codevs.cn/problem/2964/ 2964 公共素数因数  时间限制: 1 s  空间限制: 32000 KB  题目等级 : 白银 Silver 题解     ...

  4. Miller-Rabin算法 codevs 1702 素数判定 2

    转载自:http://www.dxmtb.com/blog/miller-rabbin/ 普通的素数测试我们有O(√ n)的试除算法.事实上,我们有O(slog³n)的算法. 定理一:假如p是质数,且 ...

  5. Codevs 1702 素数判定 2(Fermat定理)

    1702 素数判定 2 时间限制: 1 s 空间限制: 128000 KB 题目等级 : 钻石 Diamond 传送门 题目描述 Description 一个数,他是素数么? 设他为P满足(P< ...

  6. Miller_Rabin codevs 1702 素数判定2

    /* 直接费马小定理 */ #include<iostream> #include<cstdio> #include<cstdlib> #include<ct ...

  7. codevs 3223 素数密度

    题目描述 Description 给定区间[L, R](L <= R <= 2147483647,R-L <= 1000000),请计算区间中素数的个数. 输入描述 Input De ...

  8. codevs 1462 素数和

    1462 素数和  时间限制: 1 s  空间限制: 64000 KB  题目等级 : 青铜 Bronze     题目描述 Description 给定2个整数a,b 求出它们之间(不含a,b)所有 ...

  9. codevs 5790 素数序数

    5790 素数序数(筛素数版) 时间限制: 1 s 空间限制: 32000 KB 题目等级 : 黄金 Gold       题目描述 Description 给定一个整数n,保证n为正整数且在int范 ...

随机推荐

  1. DFS BestCoder Round #49 ($) 1001 Untitled

    题目传送门 /* DFS:从大到小取模,因为对比自己大的数取模没意义,可以剪枝.但是我从小到大也过了,可能没啥大数据 */ /************************************* ...

  2. CSS之选择符、链接、盒子模型、显示隐藏元素

    <html> <head> <meta charset="utf-8"> <title>选择符.链接.盒子模型.显示隐藏元素< ...

  3. Farseer.net轻量级开源框架 中级篇:数据库切换

    导航 目   录:Farseer.net轻量级开源框架 目录 上一篇:Farseer.net轻量级开源框架 中级篇: 动态数据库访问 下一篇:Farseer.net轻量级开源框架 中级篇: SQL执行 ...

  4. 浮动布局demo

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...

  5. 梦想CAD控件安卓选择集

    在本示例中将使用构造选择集对被过滤对象进行过滤,该类封装了选择集及其处理函数,支持如下过滤条件. 参数类型 类型 RTDXF0 TEXT 文字 MTEXT 多行文字 CIRCLE 圆 ARC 圆弧 L ...

  6. oracle查询没有主键的表

    select table_name from user_tables a where not exists (select * from user_constraints b where b.cons ...

  7. Docker 安装并定制 Nginx 服务器

    安装并定制 Nginx 1.查阅对应的官方文档,首先下载镜像文件: [spider@izwz9d74k4cznxtxjeeur9z local]$ sudo docker pull nginx [su ...

  8. JPA @MappedSuperclass注解

    该注解只能引用于类上,使用该注解的类将不是一个完整的类,不会映射到数据库的表中,但是该类的属性会映射到其子类的数据库字段中 @MappedSuperclass注解使用在父类上面,是用来标识父类的作用 ...

  9. 洛谷——P2827 蚯蚓

    P2827 蚯蚓 题目描述 本题中,我们将用符号 \lfloor c \rfloor⌊c⌋ 表示对 cc 向下取整,例如:\lfloor 3.0 \rfloor = \lfloor 3.1 \rflo ...

  10. [USACO06JAN] 牛的舞会 The Cow Prom

    题目描述 The N (2 <= N <= 10,000) cows are so excited: it's prom night! They are dressed in their ...