码迷,mamicode.com
首页 >  
搜索关键字:calculate prime s    ( 3428个结果
hdu 2012 素数判定
素数判定 题目分析: 构造一个判断素数的函数fun,利用fun函数判断区间内的素数。 代码: #include <iostream> #include <math.h> #define fun(n) n*n + n + 41 using namespace std; int prime(int n) ...
分类:其他好文   时间:2020-02-08 09:35:06    阅读次数:74
C++ primer练习3.17问题解答
问题描述:从cin中读取单词存在vector中,将其中的单词全部变为大写,并且每行八个单词进行输出。 代码(编译g++ -o vector vector.cc -std=c++11利用c11标准): 1 #include<iostream> 2 #include<string> 3 #include ...
分类:编程语言   时间:2020-02-06 12:49:51    阅读次数:68
PAT 甲级 1108 Finding Average (20分)
1108 Finding Average (20分) The basic task is simple: given N real numbers, you are supposed to calculate their average. But what makes it complicated ...
分类:其他好文   时间:2020-02-04 00:16:37    阅读次数:66
深搜--P1036选数
深搜中绝对会用到递归 因此本题也可以使用深搜来做 bool prime(int b) { memset(sz, true, sizeof(sz)); sz[1]=false; for (int i=2;i<=b;i++) { if (sz[i]) { for (int j=2*i;j<=b;j+=i ...
分类:其他好文   时间:2020-02-03 22:36:20    阅读次数:90
最小生成树
Prim、Kruskal算法求解最小生成树 [TOC] 关于最小生成树有两个很重要的算法:Prime(普利姆)算法和Kruskal(克鲁斯卡尔)算法,下面是这两个算法的代码上的基本实现: Prime算法 该算法利用了最小生成树的MST性质,该算法很好的运用了贪心算法,其基本思想是随机选取一个结点,找 ...
分类:其他好文   时间:2020-02-02 15:31:10    阅读次数:73
20200202 POJ - 3126 Prime Path POJ - 1426 Find The Multiple
>>>>>>>>>POJ 1426直达🚗 >>>>>>>>>POJ 3126直达🚗 做了这么几道搜索题,感觉差不多也摸出了门路,模板差不多记下来了,只是面对不同的题目算法不同罢了 简单写一下想法,搞明白搜索的主题到底是什么(之前的mutiple那题,一开始就没想明白到底搜谁,就没想到算法 TBC ...
分类:其他好文   时间:2020-02-02 13:39:32    阅读次数:59
筛法求素数模板1
基础知识,没什么好说的,直接上代码! 1 const int maxn = 1e8; 2 int prime[maxn+5]; 3 int len; 4 5 int initial_prime() 6 { 7 memset(prime,0,sizeof(prime)); 8 prime[0]=pri ...
分类:其他好文   时间:2020-02-01 23:09:18    阅读次数:63
HDoj 1002 A + B Problem II
Problem DescriptionI have a very simple problem for you. Given two integers A and B, your job is to calculate the Sum of A + B. InputThe first line of ...
分类:其他好文   时间:2020-02-01 16:13:15    阅读次数:69
CodeForces1288 C.Two Arrays(dp/组合数学)
C.Two ArraysYou are given two integers n and m. Calculate the number of pairs of arrays (a,b) such that: the length of both arrays is equal to m;each ...
分类:其他好文   时间:2020-02-01 12:45:43    阅读次数:197
筛质数
1 #include <iostream> 2 using namespace std; 3 4 const int N = 1e6+10; 5 6 int cnt; 7 int flag[N], prim[N]; 8 //埃式筛法 O(nlog(log(n))) 9 void get_prime( ...
分类:其他好文   时间:2020-02-01 00:57:16    阅读次数:100
3428条   上一页 1 ... 15 16 17 18 19 ... 343 下一页
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!