码迷,mamicode.com
首页 >  
搜索关键字:calculate prime s    ( 3428个结果
erlang使用gen_server实现质数服务器(手打代码,还debug了几个错误)
最近简单了解一下erlang语言,操练了一下书里的例子,有机会debug;下面是主要模块 prime_server,使用gen_server作为behaviour: 1 -module(prime_server). 2 -export([new_prime/1, start_link/0]). 3 ...
分类:其他好文   时间:2015-07-08 20:48:01    阅读次数:130
北大ACM2739——Sum of Consecutive Prime Numbers
题目的意思是:给你一个数N,求由连续的m个素数之和等于N的组数。 这题很简单,一开始没看到题目是连续的素数,所以一开始想用深搜来做,可是不行,后来再看了题目,才知道是连续的素数,是连续的素数就简单很多了。 下面的是 AC的代码: #include using namespace std; int prime[10005]; int main() { int i, j, k; for...
分类:其他好文   时间:2015-07-08 14:42:03    阅读次数:107
linux命令行计算器
在windows下,大家都知道直接运行calc,(c:\windows\system32\calc.exe),可以打开计算器。注:calculatevt.&vi.计算;calculatorn.计算器。calc就是这个计算的简写。Ca在化学中是代表钙元素,calcium钙(20号元素,符号Ca)。两者有什么联系呢?calculate来自calculus,原义是..
分类:系统相关   时间:2015-07-08 00:47:19    阅读次数:190
策略模式(strategy)
策略模式定义了一系列算法,分别封装起来,让它们之间可以相互替换,此模式让算法的变化独立于使用算法的客户。例子:public interface ICalculator { public int calculate(int a, int b); }public class Plus impl...
分类:其他好文   时间:2015-07-07 19:16:05    阅读次数:112
判断2个正整数是否互质
1. Two positive integers i and j are considered to be co-prime if there exists no integer greater than 1 that divides them both. Write a function co-....
分类:其他好文   时间:2015-07-07 14:42:25    阅读次数:108
ZOJ 3772 Calculate the Function(矩阵线段树)
Description You are given a list of numbers A1A2 .. AN and M queries. For the i-th query: The query has two parameters Li and Ri.The query will define a function Fi(x) on the domain [Li, Ri] ∈...
分类:其他好文   时间:2015-07-06 21:48:51    阅读次数:92
题——质数、因子
质数(prime number)又称素数,有无限个。一个大于1的自然数,除了1和它本身外,不能被其他自然数(质数)整除,即不再有其他的因数。如下:判断思路:对正整数n,如果用2到之间的所有整数去除,均无法整除,则n为质数。(因为 i*i= n 时, i 时中间的那个因子)#include #incl...
分类:其他好文   时间:2015-07-06 19:25:40    阅读次数:110
!POJ 2689 Prime Distance-卡时间-(素数筛法)
题意:给定两个数l,r求这之间最近和最远的两个素数。数据范围是整数的上限。r-l 分析:总思路是把l和r间的素数全部找出来,然后遍历一遍求最小距离和最大距离。用一个函数预处理数据范围内的所有素数是不现实的,一来数组不可r能开那么大二来会超时。想想素数筛的思想:用sqrt(n)以内的素数筛掉n以内的所有合数,剩下n以内的素数。这里既然预处理不可能,我们一样可以用sqrt(n)以内的素数来筛,只是这...
分类:其他好文   时间:2015-07-05 12:32:01    阅读次数:151
【C语言】编写函数实现库函数atof
//编写函数实现库函数atof #include #include #include #include double calculate(const char *src, int flag) { double num = 0.0; int n = 0; int count = 0; while (*src) { if ((*src >= '0') && (*src <= '9...
分类:编程语言   时间:2015-07-05 12:31:41    阅读次数:256
【C语言】编写函数实现库函数atoi,把字符串转换成整形(考虑数字过大)
//编写函数实现库函数atoi,把字符串转换成整形 #include #include #include #include long long calculate(const char *src, int flag) { long long num = 0; while (*src ) { if ((*src >= '0') && (*src <= '9'))//判断输?入是否为...
分类:编程语言   时间:2015-07-05 12:30:52    阅读次数:126
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!