UVa 11105 (筛法) Semi-prime H-numbers】的更多相关文章

题意: 你现在来到了一个所有的数都模4余1的世界,也就是除了这种数没有其他的数了. 然而素数的定义依然没变,如果一个数不能写成两个非1数字的乘积,则它是素数. 比如,在这里5就变成了最小的素数. 两个素数相乘得到一个半素数,比如5×5 = 25就是最小的半素数. 求1~h之间有多少个半素数. 分析: 虽然是要求[1, h]之间半素数的个数,但向往常筛普通素数一样先把所有的4k+1的素数筛出来. 然后二重循环枚举半素数,最后统计区间内[1, h]的半素数个数SUMh #include <cstdi…
类似于素数筛的思想去做,不然暴力会超时而且还要判重 #include<cstdio> #include<cstring> #include<vector> #define REP(i, a, b) for(int i = (a); i < (b); i++) using namespace std; const int MAXN = 1123456; int vis[MAXN]; vector<int> prime; int f[MAXN]; void…
版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/u011328934/article/details/36644069 option=com_onlinejudge&Itemid=8&page=show_problem&category=474&problem=2046&mosmsg=Submission+received+with+ID+13825652" rel="nofollow"…
zk has n numbers a1,a2,...,ana1,a2,...,an. For each (i,j) satisfying 1≤i<j≤n, zk generates a new number (ai+aj)(ai+aj). These new numbers could make up a new sequence b1,b2,...,bn(n−1)/2b1,b2,...,bn(n−1)/2.  LsF wants to make some trouble. While zk i…
https://vjudge.net/problem/UVA-11105 筛法 #include<cstdio> #include<cstring> #define N 1000002 using namespace std; +]; int main() { memset(v,-,sizeof(v)); ;i<N;i+=) ;i*j<N;j+=) { && v[j]==-) v[i*j]=; ; } ,s=; ;i<m;i++) { +]==)…
题意:所有形如4n+1(n为非负整数)的数叫H数.定义1是唯一的单位H数,H素数是指本身不是1,且不能写成两个不是1的H数的乘积.H-半素数是指能写成两个H素数的乘积的H数(这两个数可以相同也可以不同).输入一个H数h(h <=1000001),输出1~h之间有多少个H-半素数. 分析: 1.筛选法求H素数. 2.再枚举求H-半素数. #pragma comment(linker, "/STACK:102400000, 102400000") #include<cstdio…
Problem C: The Dragon of Loowater Once upon a time, in the Kingdom of Loowater, a minor nuisance turned into a major problem. The shores of Rellau Creek in central Loowater had always been a prime breeding ground for geese. Due to the lack of predato…
题意:题目比较容易混淆,要搞清楚一点,这里面所有的定义都是在4×k+1(k>=0)这个封闭的集合而言的,不要跟我们常用的自然数集混淆. 题目要求我们计算 H-semi-primes, H-semi-primes是 两个H-primes的乘积, H-primes的定义为:在这个集合中只能由1和它本来相乘得来,并且1不是 H-primes: 分析:这个题目我一开始是想打表记录一下的,但是没有筛法的效率,数据量过大,程序崩溃了(连超时的机会都不给我),看了多个别人的做法才知道,这个题目考查的是对于素数…
Description You've got an n × m matrix. The matrix consists of integers. In one move, you can apply a single transformation to the matrix: choose an arbitrary element of the matrix and increase it by 1. Each element can be increased an arbitrary numb…
题目描述: To facilitate the analysis of  a DNA sequence,  a DNA sequence is represented by a binary  number. The group of  DNA-1 has discovered a great new way .  There is a certain correlation between binary number and prime number. Instead of using the…