随笔分类 -  算法

上一页 1 2

摘要:方法一:暴力求解(慢O(sqrt(n)))从2开始遍历到sqrt(n),如果有能除尽的则不是素数,否则则是素数,需要空间小,速度慢。#include #include #include using namespace std;int prime(int x){ if ... 阅读全文

posted @ 2018-05-08 00:06 Radium_1209 阅读(155) 评论(0) 推荐(0)

摘要:拓扑排序(topsort)核心思想:不停找入度为零的点不断删去,并更新其他节点入度直到为空。适用范围:一些满足一定先后关系的活动排序。例题:John has n tasks to do. Unfortunately, the tasks are not indepen... 阅读全文

posted @ 2018-04-11 00:46 Radium_1209 阅读(121) 评论(0) 推荐(0)

摘要:例题:欧拉回路Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 17034 Accepted Submi... 阅读全文

posted @ 2018-04-11 00:22 Radium_1209 阅读(138) 评论(0) 推荐(0)

摘要:斯特林公式用于求n阶乘的近似值。n!的位数:lg(n!)=lg1+lg2+...+lgn向下取整+1;例题:Big NumberTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K ... 阅读全文

posted @ 2018-04-07 22:29 Radium_1209 阅读(756) 评论(0) 推荐(0)

摘要:在进行幂运算时一个一个乘需要耗费大量时间可以用一种类似二分的算法来快速运算,这就是快速幂。比如求x^n,n为偶数,x^n=(x^2)^(n/2),n为奇数,x^n=(x^2)^(n/2)*x;不停地分下去,知道n为0时停止。#include typedef long ... 阅读全文

posted @ 2018-03-27 20:47 Radium_1209 阅读(123) 评论(0) 推荐(0)

摘要:LIS:Longest Increasing Subsequence例题: 单调递增最长子序列时间限制:3000 ms | 内存限制:65535 KB难度:4描述求一个字符串的最长递增子序列的长度如:dabdbf最长递增子序列就是abdf,长度为4输入第一行一个整... 阅读全文

posted @ 2018-03-26 21:42 Radium_1209 阅读(123) 评论(0) 推荐(0)

摘要:例题:C. Rumortime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputVova promised himself... 阅读全文

posted @ 2018-03-22 23:33 Radium_1209 阅读(170) 评论(0) 推荐(0)

摘要:疯牛时间限制:1000 ms | 内存限制:65535 KB难度:4描述农夫 John 建造了一座很长的畜栏,它包括N (2 #include#includeusing namespace std;int a[100005],n,c; int judge(int ... 阅读全文

posted @ 2018-02-01 18:51 Radium_1209 阅读(309) 评论(0) 推荐(0)

上一页 1 2

导航