码迷,mamicode.com
首页 >  
搜索关键字:prime    ( 2475个结果
[leetcode] Count Primes
Count PrimesDescription:Count the number of prime numbers less than a non-negative number,nclick to show more hints.References:How Many Primes Are The...
分类:其他好文   时间:2015-05-04 21:41:10    阅读次数:112
数轮初步---无平方因子的数
这是从刘汝佳的算法竞赛入门经典中看到的题,书中是这么描述的 给出正整数n和m,输出在[m, n]中的无平方因子数。PS(无平方因子数的概念请自行百度) #include #include #include bool visited[10000005]; int prime[500000]; int main(){ int n, m; scanf("%d", &n, &m); int i,...
分类:其他好文   时间:2015-05-04 20:16:39    阅读次数:98
[LeetCode]Count Primes
Count the number of prime numbers less than a non-negative number, n 一个合数总是可以分解成若干质数的乘积。所以,如果把质数的倍数全都去掉,剩下的就是质数了。 要查找n以内的质数,首先2是质数,把2的倍数:4,6,8…去掉;此时3没有被去掉,可以认为是质数,再被3的倍数去掉;然后再到5,再到7,一直到sqrt(n)。设一个布尔类型...
分类:其他好文   时间:2015-05-04 20:15:50    阅读次数:121
poj3126 Prime Path
Description The ministers of the cabinet were quite upset by the message from the Chief of Security stating that they would all have to change the four-digit room numbers on their offices.  — It i...
分类:其他好文   时间:2015-05-04 18:17:41    阅读次数:94
杭电 HDU ACM 1016 Prime Ring Problem
Prime Ring Problem Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 31900    Accepted Submission(s): 14108 Problem Description A ring is...
分类:其他好文   时间:2015-05-04 10:06:07    阅读次数:163
求100以内的质数
求100以内的质数 By 白熊花田(http://blog.csdn.net/whiterbear) 转载需注明出处,谢谢。 描述: 输出100以内的所有素数,素数之间以一个空格区分 分析: 首先了解下素数:素数(prime number)又称质数,有无限个。一个大于1的自然数,除了1和它本身外,不能被整除以其他自然数(质数),换句话说就是该数...
分类:其他好文   时间:2015-05-03 23:46:14    阅读次数:319
8 Python Frameworks For Web Developers
Python has become immensely popular in the modern IT world. The language is most popular for its efficiency. It is also known as the best beginner’s learning language. The prime reason why Python ...
分类:编程语言   时间:2015-05-03 19:12:53    阅读次数:184
UVA - 524 Prime Ring Problem
题目大意:给出n,用1-n来组成一个环,要求相邻的两个数之和为素数。解题思路:dfs,注意判断最后一个和第一个数之和也要为素数。#include int n, vis[20], rec[20] = {1}, isPrime[50];void DFS(int cur) { if (cur == n) { if (isPrime[rec[cur - 1] + 1...
分类:其他好文   时间:2015-05-03 19:06:19    阅读次数:111
Codeforces Beta Round #92 (Div. 1 Only)
A. Prime Permutation题意:给出一个长为n的字符串,问能否通过重新排列整个字符串,使整个字符串中第i个字符$S_I$与i的素数倍数处的字符$S_prime*i$都相同关键字:[贪心]解法:打出1000内的素数表,统计i位和所有prime*i位相同需要的字符数
分类:其他好文   时间:2015-05-03 15:57:11    阅读次数:107
Count Primes
Description: Count the number of prime numbers less than a non-negative number, n References: How Many Primes Are There? Sieve of Eratosthenes 题意很简单,求n以内的素数的个数 注意:不包括n 如果注意到refe...
分类:其他好文   时间:2015-05-03 10:41:12    阅读次数:112
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!