好吧……我不会欧拉筛也就罢了……

傻逼筛法竟然这么长时间以来 一直RE ……源头竟然是 int 爆了。

 #include<cstdio>
#include<algorithm>
using namespace std;
bool vis[];
int a,b; long long ans;
void Shai()
{
vis[]=true;
for(long long i=;i<=;i++)
for(long long j=i*i;j<=;j+=i)
vis[j]=true;
}
int main()
{
scanf("%d%d",&a,&b); Shai(); if(a>b) swap(a,b);
for(int i=a+;i<b;i++) if(!vis[i]) ans+=(long long)i;
printf("%lld\n",ans);
return ;
}

【数论】【筛法求素数】CODEVS 1462 素数和的更多相关文章

  1. codevs 1462 素数和

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

  2. codevs——1462 素数和

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

  3. UVA 10006 - Carmichael Numbers 数论(快速幂取模 + 筛法求素数)

      Carmichael Numbers  An important topic nowadays in computer science is cryptography. Some people e ...

  4. 蓝桥杯 算法训练 Torry的困惑(基本型)(水题,筛法求素数)

    算法训练 Torry的困惑(基本型) 时间限制:1.0s   内存限制:512.0MB      问题描述 Torry从小喜爱数学.一天,老师告诉他,像2.3.5.7……这样的数叫做质数.Torry突 ...

  5. hdu 4548 筛法求素数 打表

    题目:http://acm.hdu.edu.cn/showproblem.php?pid=4548 Problem Description 小明对数的研究比较热爱,一谈到数,脑子里就涌现出好多数的问题 ...

  6. Eratosthenes,筛法求素数

    //筛法求区间[0,n]的所有素数,v为素数表 //v[i]==0,i为素数 void f(int n) { int m=sqrt(n+0.5); memset(v,,sizeof(v)); ;i&l ...

  7. 筛法求素数Java

    输出:一个集合S,表示1~n以内所有的素数 import java.util.Scanner; public class 筛法求素数 { public static void main(String[ ...

  8. Algorithm --> 筛法求素数

    一般的线性筛法 genPrime和genPrime2是筛法求素数的两种实现,一个思路,表示方法不同而已. #include<iostream> #include<math.h> ...

  9. JD 题目1040:Prime Number (筛法求素数)

    OJ题目:click here~~ 题目分析:输出第k个素数 贴这么简单的题目,目的不清纯 用筛法求素数的基本思想是:把从1開始的.某一范围内的正整数从小到大顺序排列, 1不是素数,首先把它筛掉.剩下 ...

随机推荐

  1. js保存用户名与密码

    <script>   window.onload = function(){     var oForm = document.getElementById('loginForm');   ...

  2. Codeforces Round #328 (Div. 2) A

    A. PawnChess time limit per test 1 second memory limit per test 256 megabytes input standard input o ...

  3. zigbee ---- endpoint理解

    很多资料将其翻译为“端点”,我们不如也这么叫. 在windows上使用不同的软件进行通信,数据包到达不同的应用的方法就是通过寻找IP地址和端口号来确定某一个应用的,也就是我们所说的五元组(源IP,目的 ...

  4. HDFS集中化缓存管理

    概述 HDFS中的集中化缓存管理是一个明确的缓存机制,它允许用户指定要缓存的HDFS路径.NameNode会和保存着所需快数据的所有DataNode通信,并指导他们把块数据缓存在off-heap缓存中 ...

  5. JS知识总结

    1.javascript继承机制 原型继承,访问对象属性时,如果对象内部有就返回,找不到就会从对象原型指向的对象原型中查找,一层一层的查找,直到最顶层的对象原型还找不到,就返回undefined. 2 ...

  6. Spring 4 + Hibernate 4 下 getCurrentSession()的使用情况

    前言:1 getCurrentSession创建的session会和绑定到当前线程,而openSession不会.   2 getCurrentSession创建的线程会在事务回滚或事物提交后自动关闭 ...

  7. hadoop之shuffle详解

    Shuffle描述着数据从map task输出到reduce task输入的这段过程. 如map 端的细节图,Shuffle在reduce端的过程也能用图上标明的三点来概括.当前reduce copy ...

  8. 【BZOJ1419】 Red is good [期望DP]

    Red is good Time Limit: 10 Sec  Memory Limit: 64 MB[Submit][Status][Discuss] Description 桌面上有R张红牌和B张 ...

  9. [bzoj2763][JLOI2011]飞行路线——分层图最短路

    水题.不多说什么. #include <bits/stdc++.h> using namespace std; const int maxn = 10010; const int maxk ...

  10. java中 快捷键输入System.out.println();

    syso 然后:alt+ /(就是问号键)