Index of super-prime Problem's Link Mean: 如果一个素数所在的位置还是素数,那么这个素数就是超级素数,比如3在第2位置,那么3就是超级素数. 现在给你一个数,求出来这个数由最少的超级素数的和组成,输出这个超级素数. analyse: 很简单的完全背包,不需要二进制压缩,也不必考虑容量. Time complexity: O(N) view code ) || )         || )        ; () ) )        ) || ) )  …
题意:用最少的super-prime组成n; 找出所有的super-prime数,只有202个.用完全背包记录能取到n值的最少数量.再找出7要哪些元素. #include <iostream> #include <cstdio> #include <cmath> #include <algorithm> #include <vector> #include <iomanip> #include <cstring> #inc…
题目大意:素数表2,3,5,7,11.....如果一个素数所在的位置还是素数,那么这个素数就是超级素数,比如3在第2位置,那么3就是超级素数.....现在给你一个数,求出来这个数由最少的超级素数的和组成,输出这个超级素数. 分析:因为给的数字并不大,所以直接用完全背包求出来即可. 代码如下: =======================================================================================================…
时间限制:0.25s 空间限制:4M 题目大意:                 在从下标1开始素数表里,下标为素数的素数,称为超级素数(Super-prime),给出一个n(n<=10000),求最少能用几个超级素数的和表示,并以降序输出这些超级素数. Sample Input 6 Sample Output 2 3 3 {=============} 分析:           读入n以后,先将不大于n的Super-prime筛出,然后DP 简单点的直接用完全背包DP, 稍微优化一点,减少一…
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,…
题目链接: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=2852 题意:找到在[1,2^64-1]区间范围内的所有Super Powers数,Super Powers数指的是可以写成另外两个正数的次幂: 例如:1=1^1,1=1^20;   64=8^2,64=4^4; 思路:1另外算,从2开始,他的指数如果不是素数,由于算数基本定理,…
POJ 2739 Sum of Consecutive Prime Numbers(素数) http://poj.org/problem? id=2739 题意: 给你一个10000以内的自然数X.然后问你这个数x有多少种方式能由连续的素数相加得来? 分析: 首先用素数筛选法把10000以内的素数都找出来按从小到大保存到prime数组中. 然后找到数X在prime中的上界, 假设存在连续的素数之和==X, 那么一定是从一个比X小的素数開始求和(不会超过X的上界),直到和sum的值>=X为止. 所…
Prime Distance Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 12811   Accepted: 3420 Description The branch of mathematics called number theory is about properties of numbers. One of the areas that has captured the interest of number th…
http://acm.sgu.ru/problemset.php?contest=0&volume=1 101 Domino 欧拉路 102 Coprime 枚举/数学方法 103 Traffic Lights 最短路 104 Little Shop of Flowers 动态规划 105 Div 3 找规律 106 The Equation 扩展欧几里德 107 987654321 Problem 找规律 108 Self-numbers II 枚举+筛法递推 109 Magic of Dav…
思路: 只保留奇数 (1)由输入的整数n确定存储奇数(不包括1)的数组大小: n=(n%2==0)?(n/2-1):((n-1)/2);//n为存储奇数的数组大小,不包括基数1 (2)由数组大小n.进程号id和进程数p,确定每个进程负责的基数数组的第一个数.最后一个数和数组维度: low_value = 3 + 2*(id*(n)/p);//进程的第一个数 high_value = 3 + 2*((id+1)*(n)/p-1);//进程的最后一个数 size = (high_value - lo…