UVA 10539 - Almost Prime Numbers(数论)】的更多相关文章

UVA 10539 - Almost Prime Numbers 题目链接 题意:给定一个区间,求这个区间中的Almost prime number,Almost prime number的定义为:仅仅能整除一个素数. 思路:既然是仅仅能整除一个素数,那么这些数肯定为素数的x次方(x > 1),那么仅仅要先打出素数表,然后在素数表上暴力找一遍就能够了,由于素数表仅仅要找到sqrt(Max),大概100W,然后每一个数找的复杂度为log(n),这样复杂度是能够接受的. 代码: #include <…
Almost prime numbers are the non-prime numbers which are divisible by only a single prime number.In this problem your job is to write a program which finds out the number of almost prime numberswithin a certain range.InputFirst line of the input file c…
题意:输入两个正整数L.U(L<=U<1012),统计区间[L,U]的整数中有多少个数满足:它本身不是素数,但只有一个素因子. 分析: 1.满足条件的数是素数的倍数. 2.枚举所有的素数,以及其倍数,将满足条件且小于等于n的个数计算出来,solve(u) - solve(l - 1)即可. #pragma comment(linker, "/STACK:102400000, 102400000") #include<cstdio> #include<cst…
  Carmichael Numbers  An important topic nowadays in computer science is cryptography. Some people even think that cryptography is the only important field in computer science, and that life would not matter at all without cryptography. Alvaro is one…
UVA 1415 - Gauss Prime 题目链接 题意:给定a + bi,推断是否是高斯素数,i = sqrt(-2). 思路:普通的高斯素数i = sqrt(-1),推断方法为: 1.假设a或b为0.推断还有一个数为4 * n + 3形式的素数(用到费马平方和定理) 2.假设a.b都不为0,推断a ^ 2 + b ^ 2 是否为素数 那么这题,提取出sqrt(2)来,就和基本情况一样了. 对于2,变成: 假设a.b都不为0,推断a ^ 2 + 2 b ^ 2是否为素数 对于1.事实上仅仅…
Sum of Consecutive Prime Numbers Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 20050   Accepted: 10989 Description Some positive integers can be represented by a sum of one or more consecutive prime numbers. How many such representatio…
题目链接: 传送门 Sum of Consecutive Prime Numbers Time Limit: 1000MS     Memory Limit: 65536K Description Some positive integers can be represented by a sum of one or more consecutive prime numbers. How many such representations does a given positive intege…
Sieve of Eratosthenes (素数筛选算法) Given a number n, print all primes smaller than or equal to n. It is also given that n is a small number. For example, if n is 10, the output should be “2, 3, 5, 7″. If n is 20, the output should be “2, 3, 5, 7, 11, 13,…
Problem Description Give you a lot of positive integers, just to find out how many prime numbers there are. Input There are a lot of cases. In each case, there is an integer N representing the number of integers to find. Each integer won't exceed 32-…
题目链接:Codeforces 385C Bear and Prime Numbers 这题告诉我仅仅有询问没有更新通常是不用线段树的.或者说还有比线段树更简单的方法. 用一个sum数组记录前n项和,这个sum数组在打素数表时候就能够求出来,注意一点求素数的内层循环要改成i.不能再写成i + i或者i * i了.原因想想就明确了. 这学期最后一场比赛也结束了,结果不非常惬意但也还好. 总的来说这学收获还是蛮多的. 近期可能就不再做ACM了吧,可能要复习CET6了吧,可能要复习期末考试的内容了吧.…