随笔分类 -  数学

light oj 1098 数学规律
摘要:1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #include 9 #define ll long long 10 11 using namespace std; 12 13 14 const ll MAX = (ll)sqrt(2e9)+1; ... 阅读全文

posted @ 2016-08-13 13:48 鱼泪儿 阅读(264) 评论(0) 推荐(0)

light oj 1095 组合数学
摘要:1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #include 9 #define ll long long 10 11 using namespace std; 12 13 14 const int MAX = 200005; 15 const... 阅读全文

posted @ 2016-08-11 18:38 鱼泪儿 阅读(203) 评论(0) 推荐(0)

逆康托展开
摘要:1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #define LL long long 9 10 using namespace std; 11 12 void unCantor(int X,int n) 13 { 14 int a[20],... 阅读全文

posted @ 2016-08-01 09:12 鱼泪儿 阅读(153) 评论(0) 推荐(0)

康托展开
摘要:1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #define LL long long 9 10 using namespace std; 11 12 //X = a[1]*(n-1)!+a[2]*(n-2)!+...+a[i]*(n-i)!+...... 阅读全文

posted @ 2016-07-31 17:39 鱼泪儿 阅读(136) 评论(0) 推荐(0)

约瑟夫问题
摘要:这个问题其实还蛮有名的,它被称为约瑟夫的问题。 最直观的解法是用循环链表模拟报数、淘汰的过程,复杂度是O(NM)。 今天我们来学习两种更高效的算法,一种是递推,另一种也是递推。第一种递推的公式为: 接下来我们用数学归纳法来证明这个递推公式的正确性: (1) f[1] = 0 显然当只有1个候选人时, 阅读全文

posted @ 2016-05-18 15:45 鱼泪儿 阅读(276) 评论(0) 推荐(0)

Eular质数筛法
摘要:小Hi:我们可以知道,任意一个正整数k,若k≥2,则k可以表示成若干个质数相乘的形式。Eratosthenes筛法中,在枚举k的每一个质因子时,我们都计算了一次k,从而造成了冗余。因此在改进算法中,只利用k的最小质因子去计算一次k。 首先让我们了解一下Eular筛法,其伪代码为: isPrime[] 阅读全文

posted @ 2016-05-18 12:33 鱼泪儿 阅读(327) 评论(0) 推荐(0)

质数测试
摘要:也即是说:假设我们要测试n是否为质数。我们可以随机选取一个数a,然后计算a^(n-1) mod n,如果结果不为1,我们可以100%断定n不是质数。 否则我们再随机选取一个新的数a进行测试。如此反复多次,如果每次结果都是1,我们就假定n是质数。 该测试被称为Fermat测试。需要注意的是:Ferma 阅读全文

posted @ 2016-05-18 11:49 鱼泪儿 阅读(385) 评论(0) 推荐(0)

常用排序的实现方法(数据结构)
摘要:快排: 思想:通过一趟排序将要排序的数据分割成独立的两部分,其中一部分的所有数据都比另外一部分的所有数据都要小,然后再按此方法对这两部分数据分别进行快速排序,整个排序过程可以递归进行,以此达到整个数据变成有序序列。 代码: 1 #include <iostream> 2 using namespac 阅读全文

posted @ 2016-02-18 18:41 鱼泪儿 阅读(290) 评论(0) 推荐(0)

关于整数的整数因子和问题的若干研究(数学)
摘要:奉上原作链接:http://wenku.baidu.com/view/e55ca209ba1aa8114431d98a.html 算数基本定理:每个大于1的自然数均可写为质数的积,而且这些素因子按大小排列之后,写法仅有一种方式(在排列组合中也有讲)。例如:1200 = 24*3*52。 待续。。 阅读全文

posted @ 2016-02-18 12:02 鱼泪儿 阅读(230) 评论(0) 推荐(0)

高斯消元模板,整数(数学)
摘要:线性代数,原理不讲了。。。 1 /* 用于求整数解得方程组. */ 2 3 #include <iostream> 4 #include <string> 5 #include <cmath> 6 using namespace std; 7 8 const int maxn = 105; 9 10 阅读全文

posted @ 2016-02-17 17:34 鱼泪儿 阅读(392) 评论(0) 推荐(0)

Jan's light oj 01--二分搜索篇
摘要:碰到的一般题型:1.准确值二分查找,或者三分查找(类似二次函数的模型)。 2.与计算几何相结合答案精度要求比较高的二分查找,有时与圆有关系时需要用到反三角函数利用 角度解题。 3.不好直接求解的一类计数问题,利用二分直接枚举可能的结果,再检查是否符合题目要求。 4.区间求解,即利用两次二分分别查找有 阅读全文

posted @ 2016-02-03 18:59 鱼泪儿 阅读(213) 评论(0) 推荐(0)

light oj 1138
摘要:Trailing Zeroes (III)Time Limit: 2000MSMemory Limit: 32768KB64bit IO Format: %lld & %llu Submit Status DescriptionYou task is to find minimal natural ... 阅读全文

posted @ 2015-08-21 13:49 鱼泪儿 阅读(225) 评论(0) 推荐(0)

hihocoder 1142 三分·三分求极值(三分)
摘要:题目1 : 三分·三分求极值时间限制:10000ms单点时限:1000ms内存限制:256MB描述 这一次我们就简单一点了,题目在此:在直角坐标系中有一条抛物线y=ax^2+bx+c和一个点P(x,y),求点P到抛物线的最短距离d。提示:三分法输入第1行:5个整数a,b,c,x,y。前三个数构成抛物... 阅读全文

posted @ 2015-08-17 16:23 鱼泪儿 阅读(255) 评论(0) 推荐(0)

zoj 1028 Flip and Shift(数学)
摘要:Flip and ShiftTime Limit: 2 Seconds Memory Limit: 65536 KBThis puzzle consists of a random sequence of m black disks and n white disks on an oval-s... 阅读全文

posted @ 2015-08-16 14:46 鱼泪儿 阅读(429) 评论(0) 推荐(0)

导航