POJ 2739 Sum of Consecutive Prime Numbers Time Limit:1000MS Memory Limit:65536KB 64bit IO Format:%lld & %llu Description Some positive integers can be represented by a sum of one or more consecutive prime numbers. How many such representati…
质数(prime number)又称素数,有无限个.一个大于1的自然数,除了1和它本身外,不能被其他自然数整除,换句话说就是该数除了1和它本身以外不再有其他的因数:否则称为合数. 最小的质数是2. [例1]Goldbach's Conjecture (POJ 2262) Description In 1742, Christian Goldbach, a German amateur mathematician, sent a letter to Leonhard Euler in w…
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…
题目链接:http://poj.org/problem?id=2739 预处理出所有10001以内的素数,按照递增顺序存入数组prime[1...total].然后依次处理每个测试数据.采用双重循环计算n的表示数: 外循环i : for (i = 0; x >= prime[i]; i++) 的循环结构枚举所有可能的最小素数prime[i]: 内循环: while (ans < x && j < total) ans += prime[j++]; 计算连续…
题目链接: 传送门 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…