ICode9

精准搜索请尝试: 精确搜索
  • M - Prime Friend(HDU 3823)2019-08-05 09:00:30

    题目链接 题解 题意: 给定a、b两个数,求能使a+c、b+c为素数且中间无其他素数的整数c,不存在这样的c则输出-1。 思路: 打表,暴力 Code #include <vector> #include <map> #include <set> #include <algorithm> #include <iostream> #include <cstdio> #include <cmath> #inclu

  • LiberOJ #124. 除数函数求和 【整除分块】2019-07-25 17:01:52

    一、题目   #124. 除数函数求和 二、分析   比较好的一题,首先我们要对题目和样例进行分析,明白题目的意思。   由于对于每一个$d$,它所能整除的数其实都是定的,且数量是$ \lfloor \frac{n}{d} \rfloor $ 最终推导出这个公式 $$  ans =   \sum_{d=1}^{n} \lfloor \frac{n}{d}

  • 返回小于 N 的质数个数 C++解法2019-07-21 11:41:15

    题目描述 请考虑性能 输入描述: 一个整数N 输出描述: 小于N的质数数量 示例1 输入 10 输出 4 说明 N=10,质数有 [2, 3, 5, 7] #include <bits/stdc++.h> using namespace std; bool isPrime(int n) //判断一个数是否为质数 { if (n <= 1) return false; else { for

  • PAT甲级 1015 Reversible Primes 进制转化+反转+判断素数2019-07-15 21:03:46

    代码如下: //数的反转、判断素数、进制间的转化 #include<iostream> #include<stdio.h> using namespace std; int num[100];//记录转化为radex进制数每位的数组 bool isprime(int x){//判断素数 if(x==1){ return false; } for(int i=2;i*i<=x;i++){ if(x%

  • poj2689 Prime Distance(素数区间筛法)2019-07-09 16:53:27

    题目链接:http://poj.org/problem?id=2689 题目大意:输入两个数L和U(1<=L<U<=2 147 483 647),要找出两个相邻素数C1和C2(L<=C1<C2<=U)是距离最小的,如果相邻素数不止一对,选择最初的,还要找出两个相邻的素数D1,和D2是距离最大的(同样在有多对的情况下选择最初的) 其中L<U,L和U的差不超过1 000

  • PAT_A1116#Come on! Let's C2019-06-11 21:03:33

    Source: PAT A1116 Come on! Let's C (20 分) Description: "Let's C" is a popular and fun programming contest hosted by the College of Computer Science and Technology, Zhejiang University. Since the idea of the contest is for fun, the a

  • PAT 1015 Reversible Primes2019-05-11 16:54:52

    A reversible prime in any number system is a prime whose "reverse" in that number system is also a prime. For example in the decimal system 73 is a reversible prime because its reverse 37 is also a prime. Now given any two positive integers N (&

  • 寻找孪生素数2019-03-28 19:40:04

    数学家希尔伯特在1900年国际数学家大会的报告上提出一个“孪生素数猜想”,即: 存在无穷多个素数p,使得p + 2是素数。p和p+2这一对差为2的素数,被称为“孪生素数”。看起来,这个猜想是成立的,我们总能找到很多对孪生素数,例如:3和5,5和7,11和13…… 这一猜想至今还未被证明。现在,对于给定的

  • Eratosthenes筛法2019-03-18 16:49:30

    概况 Eratosthenes筛法是一个素数筛法,可以在近线性时间内制作出\(1-n\)的素数表。 \(\mathfrak{Eratosthenes}\)筛法 思想很简单。对于一个正整数\(p(p\in[1,n])\),筛除\(2p,3p,4p,...\),待将所有数处理完以后,剩下的就都是指质数了。 同时,我们还可以限定\(p\)为质数。 inline void E

  • P4450 双亲数2019-03-01 19:47:30

    思路 同zap-queries 莫比乌斯反演的板子 数据范围小到不用整除分块。。。 代码 #include <cstdio> #include <algorithm> #include <cstring> #define int long long using namespace std; int mu[1010000],isprime[1010000],iprime[1010000],cnt,n,m,d; void prime(int n){ is

  • ☆10782019-02-24 14:01:17

     开放定址法中的平方探测法使用时是有条件的。对于本题,存在hash不满,但始终无法填入key的情况。 当  step >= msize 时,若还找不到空位,便不可能找到了。 1 #include <iostream> 2 #include <cmath> 3 #include <cstdio> 4 using namespace std; 5 6 bool isprime(int x){

  • 欧拉函数学习笔记2019-01-21 11:00:10

    什么是欧拉函数 记欧拉函数为\(\varphi(x)\)表示比\(x\)小且与\(x\)互质的数的个数。 怎么算欧拉函数 通项公式:\(\varphi(x)=x*\prod(1-\frac{1}{p_i})\) (\(p_i\)为\(x\)的质因数) 因为欧拉函数是一个积性函数,因此我们可以用欧拉筛(线性筛)在\(O(n)\)的时间内预处理出来:具体证明

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有