码迷,mamicode.com
首页 >  
搜索关键字:prime    ( 2475个结果
POJ3126 Prime Path
http://poj.org/problem?id=3126题目大意:给两个数四位数m, n, m的位数各个位改变一位0 —— 9使得改变后的数为素数,问经过多少次变化使其等于n如:1033173337333739377987798179分析:用字符串存m,n,这样改变各个位较方便数组开大一点,开始...
分类:其他好文   时间:2015-07-20 21:30:48    阅读次数:126
SGU[116] Index of super-prime
Description描述Let P1, P2, … ,PN, … be a sequence of prime numbers. Super-prime number is such a prime number that its current number in prime numbers s...
分类:其他好文   时间:2015-07-20 14:24:06    阅读次数:121
C/C++经典书籍推荐
C语言要从大而全,从基础开始,它属于最好的。别被它误导,它也有很多错误,不适合标准软件开发者使用,变量声明,定义,编程规范完全不合格,但是从语言学习方面做到极致,有大量不同的例子和试题,标准的教科书始的书籍:《C语言程序设计》(谭浩强) c++基础语言学习它应该是老大,从基础教起,面面具到,但是他同样少不了老外书籍的弊病,整本书总是拿那几个示例摆弄来摆弄去,没有新意,不利于面的扩展。这虽然增加了...
分类:编程语言   时间:2015-07-20 13:00:03    阅读次数:172
USACO Prime Palindromes(dfs)
题目请点我 题解: 这道题看起来是一道很简单的题目,但是数据量很大。如果暴力判断会超时,预处理筛法标记素数则会超内存。最后看了网上的解法才知道要逆推,生成回文数,这还是要第一次遇到。并且很重要的一点是偶数位的回文数都能被11整除,所以只需要生成奇数位的,偶数位回文素数符合情况的值可能有11一个。挺考验思维的,重要的是do mathmatics first. 代码实现:/* ID: eashio...
分类:其他好文   时间:2015-07-19 16:33:40    阅读次数:148
POJ 3126 Prime Path (BFS)
【题目链接】click here~~ 【题目大意】给你n,m分别是素数,求由n到m变化的步骤数,规定每一步只能改变个十百千一位的数,且变化得到的每一个数也为素数 【解题思路】和poj 3278类似,bfs+queue,分别枚举个十百千的每一位就可以了,不过注意个位只能为奇数,且千位从1开始 代码: //poj 3126 #ifndef _GLIBCXX_NO_ASSERT #include...
分类:其他好文   时间:2015-07-19 11:54:31    阅读次数:131
Project Euler:Problem 77 Prime summations
It is possible to write ten as the sum of primes in exactly five different ways: 7 + 3 5 + 5 5 + 3 + 2 3 + 3 + 2 + 2 2 + 2 + 2 + 2 + 2 What is the first value which can be written as the sum o...
分类:其他好文   时间:2015-07-18 18:40:05    阅读次数:118
Cpp的Virtual函数不能只声明不定义
在《C++ Prime 中文版 第五版》的451页提到:声明但是不定义一个成员函数是合法的,对此只有一个例外,我们将在15.2.1节(528页)介绍。翻到528页,是介绍虚函数的地方。针对于此,使用VS2010编译环境进行验证。代码1:声明但是不定义virtual函数#include using n...
分类:其他好文   时间:2015-07-18 12:30:50    阅读次数:200
Project Euler:Problem 70 Totient permutation
Euler's Totient function, φ(n) [sometimes called the phi function], is used to determine the number of positive numbers less than or equal to n which are relatively prime to n. For example, as 1, 2,...
分类:其他好文   时间:2015-07-17 14:04:42    阅读次数:142
Project Euler:Problem 69 Totient maximum
Euler's Totient function, φ(n) [sometimes called the phi function], is used to determine the number of numbers less than n which are relatively prime to n. For example, as 1, 2, 4, 5, 7, and 8, are ...
分类:其他好文   时间:2015-07-17 10:05:11    阅读次数:174
Prime counting,sum of primes,leetcode,dp.
主要参考 http://www.zhihu.com/question/29580448/answer/45218281https://projecteuler.net/thread=10;page=5 Lucy_Hedgehog的代码如果不用map,自己写hash函数会更快// 计算 Π(n-1)c...
分类:其他好文   时间:2015-07-16 19:35:37    阅读次数:166
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!