![](https://img-blog.csdnimg.cn/20201014180756930.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
——数论——
TheWise_lzy
已毕业,社畜一枚
展开
-
组合数学 卡特兰数 解释与应用
卡特兰数(Catalan number)是 组合数学 中一个常出现在各种 计数问题 中的 数列。 数列的前几项为:1, 1, 2, 5, 14, 42, 132, 429, 1430, 4862,... f(n)= f(0)*f(n-1)+f(1)*f(n-2) + ... + f(n-1)*f(0) (n>=2) = C(2*n,n)/(n+1) 实现代码: // 打印前 n 个卡特兰数 // 当 n 等于 17 时,卡特兰数将会超过 int 最大值 int ans=1,n.原创 2022-03-01 19:06:27 · 1251 阅读 · 0 评论 -
ACM 容斥原理 TOJ4008 The Leaf Eaters
TOJ 4008 The Leaf Eaters 描述 As we all know caterpillars love to eat leaves. Usually, a caterpillar sits on leaf, eats as much of it as it can (or wants), then stretches out to its full length to re...原创 2017-04-07 21:07:57 · 670 阅读 · 0 评论 -
ACM 二分 Aggressive cows & 尺取 Subsequence
滴,集训第三天打卡。 今天是堆,二分和尺取,不过我好像没做到用堆的... 二分的套路是: while(f<=l)//二分 { mid=(f+l)/2; if(hs(mid))//判断中间值是否满足条件 f=mid+1; else l=mid-1; } 尺取法:尺取法通常是对数组保存一对下标,即所选取的区间的左右端点,然后根据实际情况不断地推进区间左右端点以得...原创 2017-07-20 10:50:57 · 433 阅读 · 0 评论 -
ACM 斯特林公式 Factorial vs Power
斯特林公式(Stirling's approximation)是一条用来取n的阶乘的近似值的数学公式。一般来说,当n很大的时候,n阶乘的计算量十分大,所以斯特林公式十分好用,而且,即使在n很小的时候,斯特林公式的取值已经十分准确。 SPOJ Factorial vs Power 题目大意:对于给定的a,求满足的 n! > an 最小的n。 思路:利用斯特林公式,可以代替...原创 2017-07-23 17:43:50 · 471 阅读 · 0 评论 -
Vivian's Problem 梅森素数
所谓梅森数,是指形如2p-1的一类数,其中指数p是素数,常记为Mp 。如果梅森数是素数,就称为梅森素数。 关于梅森素数,有一个重要的定理:“一个数能够写成几个不重复的梅森素数的乘积” 等价于 “这个数的约数和是2的幂次”,但是不能重复,比如说3是梅森素数,9就不满足约数和为2的幂。 Vivian's Problem(Asia Guangzhou 2003) The d...原创 2017-09-08 17:24:32 · 755 阅读 · 0 评论 -
TOJ 2931 Raising Modulo Numbers 快速幂
今天和王学长谈人生谈了两个小时后,假装大彻大悟。 (决定,要重新学一遍算法了... 快速幂详解: 对于任何一个整数的模幂运算 a^b%c 对于b我们可以拆成二进制的形式 b=b0+b1*2+b2*2^2+...+bn*2^n 这里我们的b0对应的是b二进制的第一位 那么我们的a^b运算就可以拆解成 a^b0*a^b1*2*...*a^(bn*2^n) 对于b来说,...原创 2017-11-27 22:26:25 · 239 阅读 · 0 评论 -
TOJ 1086 Round and Round We Go 大数相乘
1086: Round and Round We Go 时间限制(普通/Java):1000MS/10000MS 内存限制:65536KByte 总提交: 254 测试通过:165 描述 A cyclic number is an integer n digits in length which, when multiplied by any integer ...原创 2018-10-10 10:43:45 · 387 阅读 · 0 评论 -
TOJ 1226: Last non-zero Digit in N! 求N!第一个不为0的尾数
1226: Last non-zero Digit in N! 时间限制(普通/Java):1000MS/10000MS 内存限制:65536KByte 总提交: 301 测试通过:102 描述 The expression N!, read as "N factorial," denotes the product of the first N positi...原创 2018-10-13 17:54:41 · 228 阅读 · 0 评论 -
POJ2065 TOJ1028 :SETI 高斯消元
描述 For some years, quite a lot of work has been put into listening to electromagnetic radio signals received from space, in order to understand what civilizations in distant galaxies might be trying ...原创 2018-10-24 21:17:37 · 255 阅读 · 0 评论 -
POJ1222 TOJ2005 Extended Lights Out 高斯消元
描述 In an extended version of the game Lights Out?, is a puzzle with 5 rows of 6 buttons each (the actual puzzle has 5 rows of 5 buttons each). Each button has a light. When a button is pressed, that ...原创 2018-10-24 21:07:55 · 200 阅读 · 0 评论 -
POJ2947 TOJ1799: Widget Factory 高斯消元
描述 The widget factory produces several different kinds of widgets. Each widget is carefully built by a skilled widgeteer. The time required to build a widget depends on its type: the simple widgets n...原创 2018-10-25 16:48:17 · 186 阅读 · 0 评论