
数论
文章平均质量分 63
ZCY19990813
不断丰富自己,变得有底气!
展开
-
基础数论(逆元,中国剩余定理)(模板~)
一 逆元1.逆元的含义:模n意义下,1个数a如果有逆元x,那么除以a相当于乘以x。2 方法(1)费马小定理在模为素数p的情况下,有费马小定理a^(p-1)=1(mod p)那么a^(p-2)=1/a(mod p)(2)扩展欧几里得算法 a∗x+b∗y=gcd(a,b)ll exgcd(ll a,ll b,ll &x,ll &y){ ...原创 2018-07-20 11:33:21 · 393 阅读 · 0 评论 -
几种数学公式(环排列 母函数 唯一分解定理 卡特兰数 默慈金数 贝尔数 那罗延数)
一:环排列把一个m个元素的环在m个不同的位置拆开记得到m个不同的线排列。由于n个不同元素中任取m个元素的排列方法为P(n,m)种,所以n个不同元素中任取m个元素的环排列方法有P(n,m)/m种。(p是排列组合中的A)特别的,n个不同元素的环排列方法有P(n,n)/n=(n-1)!种。二:母函数(用来解决:有N种重量的物品,每种物品有M个(1-无穷),求可以组合出来的重量的个数和该重量的方...原创 2018-07-24 15:05:23 · 1441 阅读 · 2 评论 -
Fishermen(2018 ICPC SouthEastern European)
Input8 4 47 23 34 55 12 21 48 49 46 1 4 9Output2232题意:有n条鱼,m个渔夫,且这m个渔夫都在横坐标轴上,每个渔夫都有一个长度为L的鱼竿,当鱼和渔夫距离小于或等于L时,鱼能被钓到。并且渔夫(x,0)与鱼(a,b)的距离满足如下公式|a − x| + b. 式子中x为渔夫的横坐标,(a,b)为...原创 2019-07-31 10:48:08 · 301 阅读 · 0 评论 -
Jamie and Binary Sequence (changed after round)(Codeforces 916B)
Sample InputInput23 5OutputYes3 3 2 1 0 Input13 2OutputNoInput1 2OutputYes-1 -1 HintSample 1:2^3 + 2^3 + 2^2 + 2^1 + 2^0 = 8 + 8 + 4 + 2 + 1 = 23Answers like(3, 3, 2, 0, 1)or...原创 2019-08-01 17:34:14 · 236 阅读 · 0 评论 -
Take Your Seat(概率计算)
Duha decided to have a trip to Singapore by plane.The airplane had nn seats numbered from 11 to nn , and nn passengers including Duha which were also counted from 11 to nn . The passenger with numbe...原创 2019-08-18 20:36:29 · 1025 阅读 · 0 评论 -
J集合的最小值(计蒜课 联盟周赛)费马小定理求逆元
n 个数可以选出 2^n - 1 个集合 (集合元素可相同)。每个集合价值为:集合里最大值乘集合里最小值( max×min )。求所有集合的价值的和并对 1000000007 取模。输入格式第一行有一个正整数 n。接下来一行 n 个数 s1,s2,s3,s4,⋯,sn 表示集合里的元素输出格式每一行一个答案取模就是取余数 a 模 b (a mod b) 就是 a÷b...原创 2019-08-10 21:48:35 · 613 阅读 · 0 评论 -
Box(gym 101630 B)
原文地址B题Bella is working in a factory that produces boxes. All boxes are in a shape of rectangular parallelepipeds.A net of the corresponding parallelepiped is cut out of a flat rectangular piece of ...原创 2019-08-21 12:41:37 · 678 阅读 · 1 评论 -
Chat Group(CFGym 101775A ) (费马小定理求逆元)
It is said that a dormitory with 6 persons has 7 chat groups^_^. But the number can be even larger: since every 3 or more persons could make a chat group, there can be 42 different chat groups.Give...原创 2019-08-22 10:00:23 · 392 阅读 · 0 评论