
数论相关
文章平均质量分 74
nka_kun
ACMer
展开
-
n阶乘后面0的个数+组合数学结果0的个数举例+公式推导
先挂上一题,用作例子。(n!%(10^k))==0.已知n,求能使上式成立的k的最大值。例如 5!= 120 有1个0,10!= 3628800 ,有2个0。很明显,阶乘中所有数的因子中有一个2和一个5即产生一个0。但是转念想到,因子2明显比5多,所有只计算5的个数就可以。10! = 10*9*8*7*6*5*4*3*2*1,5分离出来一个5,10也分离出来一原创 2017-06-10 22:08:30 · 3825 阅读 · 1 评论 -
CodeForces - 959E Mahmoud and Ehab and the xor-MST(异或)
Mahmoud and Ehab and the xor-MSTEhab is interested in the bitwise-xor operation and the special graphs. Mahmoud gave him a problem that combines both. He has a complete graph consisting of n vertices ...原创 2018-05-09 19:04:46 · 385 阅读 · 0 评论 -
2018第九届蓝桥杯B组决赛题解第三题 格雷码
标题:格雷码格雷码是以n位的二进制来表示数。与普通的二进制表示不同的是,它要求相邻两个数字只能有1个数位不同。首尾两个数字也要求只有1位之差。有很多算法来生成格雷码。以下是较常见的一种:从编码全0开始生成。当产生第奇数个数时,只把当前数字最末位改变(0变1,1变0)当产生第偶数个数时,先找到最右边的一个1,把它左边的数字改变。用这个规则产生的4位格雷码序列如下:000000010011 001...原创 2018-05-28 20:09:56 · 3855 阅读 · 1 评论 -
2018第九届蓝桥杯B组决赛题解第六题 矩阵求和
标题:矩阵求和经过重重笔试面试的考验,小明成功进入 Macrohard 公司工作。今天小明的任务是填满这么一张表:表有 n 行 n 列,行和列的编号都从1算起。其中第 i 行第 j 个元素的值是 gcd(i, j)的平方,gcd 表示最大公约数,以下是这个表的前四行的前四列:1 1 1 11 4 1 41 1 9 11 4 1 16小明突然冒出一个奇怪的想...原创 2018-05-28 20:34:20 · 4684 阅读 · 5 评论 -
HDU-6189 Law of Commutation(数学)
Law of Commutation Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) ...原创 2018-07-16 10:30:32 · 300 阅读 · 0 评论 -
HDU-5852 Intersection is not allowed!(Lindström–Gessel–Viennot lemma+行列式)
Intersection is not allowed! Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) ...原创 2018-07-21 11:05:10 · 241 阅读 · 0 评论 -
HDU-6333 Harvest of Apples(组合数推导+莫队)
Harvest of Apples Time Limit: 4000/2000 MS (Ja...原创 2018-08-02 10:40:58 · 198 阅读 · 0 评论 -
计蒜客-Exponial(欧拉降幂)
题目:https://nanti.jisuanke.com/t/17414题意:给出一个n(1~1e9),m(1~1e9),求exponial(n)%m的值思路:欧拉降幂注意n<= 4的时候的特判,因为我们没法直接判出B是否小于phi(C),因为递归得来的B已经是模phi(phi(C))的结果.欧拉函数:对一个正整数N,欧拉函数是小于N且与N互质的数的个数.例如φ...原创 2018-08-11 11:03:07 · 282 阅读 · 0 评论 -
51Nod 1060 最复杂的数(反素数)
1060 最复杂的数基准时间限制:1 秒 空间限制:131072 KB把一个数的约数个数定义为该数的复杂程度,给出一个n,求1-n中复杂程度最高的那个数。例如:12的约数为:1 2 3 4 6 12,共6个数,所以12的复杂程度是6。如果有多个数复杂度相等,输出最小的。Input第1行:一个数T,表示后面用作输入测试的数的数量。(1 <= T <= 100)第2 - T +...原创 2018-10-05 21:37:01 · 257 阅读 · 0 评论 -
Codeforces Round #428 (Div. 2) Journey(数学期望+dfs)
There are n cities and n - 1 roads in the Seven Kingdoms, each road connects two cities and we can reach any city from any other by the roads.Theon and Yara Greyjoy are on a horse in the first city, they are starting traveling through the roads. But the原创 2017-08-13 10:57:42 · 488 阅读 · 0 评论 -
第13届景驰-埃森哲杯广东工业大学ACM程序设计大赛 C-平分游戏
链接:https://www.nowcoder.com/acm/contest/90/C来源:牛客网集训队一共有n位同学,他们都按照编号顺序坐在一个圆桌旁。第i位同学一开始有a[i]个硬币,他们希望使得每位同学手上的硬币变成相同的数目。每一秒钟,有且仅有一位同学可以把自己手上的一枚硬币交给另一位同学,其中这两位同学中间必须间隔k位同学。现在问的是最少几秒后所有同学手上的有相同数量的硬币输入描述:第...原创 2018-03-27 16:12:59 · 205 阅读 · 0 评论 -
POJ 1190 生日蛋糕(深搜+剪枝)
生日蛋糕Time Limit: 1000MS Memory Limit: 10000KTotal Submissions: 20096 Accepted: 7151Description7月17日是Mr.W的生日,ACM-THU为此要制作一个体积为Nπ的M层生日蛋糕,每层都是一个圆柱体。 设从下往上数第i(1 Ri+原创 2017-07-29 16:32:25 · 410 阅读 · 2 评论 -
Lengthening Sticks(容斥,组合数学)
Lengthening Stickstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given three sticks with positive integer lengths of a, b, and c centimeters. You can increase length of some of them by some原创 2017-11-04 13:44:34 · 436 阅读 · 0 评论 -
CodeForces - 635C XOR Equation(搜索||数论)
XOR EquationTwo positive integers a and b have a sum of s and a bitwise XOR of x. How many possible values are there for the ordered pair (a, b)?InputThe first line of the input contains two integers ...原创 2018-03-19 21:30:00 · 268 阅读 · 0 评论 -
2018省赛第九届蓝桥杯真题C语言B第三题题解 乘积尾零
2018第九届蓝桥杯C++省赛B组[最新题解汇总]标题:乘积尾零如下的10行数据,每行有10个整数,请你求出它们的乘积的末尾有多少个零?5650 4542 3554 473 946 4114 3871 9073 90 4329 2758 7949 6113 5659 5245 7432 3051 4434 6704 3594 9937 1173 6866 3397 4759 7557 3070 2...原创 2018-04-02 10:13:15 · 2051 阅读 · 3 评论 -
HDU4704 Sum(大数取模,深刻理解费马小定理)
SumSimple Input23Simple Output24思路:原题把人坑死,原来交换位置算新的一种.插板法 C(1,n)+C(2,n)+······+C(n,n) = 2^n.即求2^(n-1),但是n极大,这里取模运算就用到了大数取模和费马小定理.假如a,p互质,则a^(p-1)%p == 1恒成立,所以此题是不是可以利用这一性质呢.因为2^n %p== 2^(p-1)*2(n-(p-1...原创 2018-04-09 15:13:26 · 428 阅读 · 0 评论 -
HDU 5719Arrange(类似排列组合问题)
ArrangeTime Limit: 8000/4000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 1191 Accepted Submission(s): 404Problem DescriptionAccidentally, Cupid, god of desir...原创 2017-11-11 17:23:38 · 491 阅读 · 0 评论 -
HDU5685 (费马小定理,逆元)
Problem ATime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1537 Accepted Submission(s): 691Problem Description度熊手上有一本字典存储了大量的单词,有一次,他把所有单词组成了一个...原创 2017-11-08 19:55:32 · 507 阅读 · 0 评论 -
HDU 1495 非常可乐(BFS||数论)
非常可乐Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 16087 Accepted Submission(s): 6493Problem Description大家一定觉的运动以后喝可乐是一件很惬意的事情,但是seeyou却不这么认...原创 2017-07-28 21:39:55 · 532 阅读 · 0 评论 -
CodeForces - 27E Number With The Given Amount Of Divisors(恰好有n个因子的数)
Given the number n, find the smallest positive integer which has exactly n divisors. It is guaranteed that for the given n the answer will not exceed 10^18.InputThe first line of the input contains ...原创 2018-10-05 21:46:44 · 281 阅读 · 0 评论