数学
文章平均质量分 87
用于记录自己学习数学的过程
和 一些有关数学的题解
kitalekita
如果你觉得自己很菜,请你努力,因为你不努力更菜
展开
-
ABC221E LEQ
ABC221E(树状数组+乘法逆元)题目链接Problem StatementGiven is a sequence of NNN integers:$ A = (A_1, A_2, \dots, A_N)$Find the number of (not necessarily contiguous) subsequences A′=(A1′,A2′,…,Ak′)A'=(A'_1,A'_2,\ldots,A'_k)A′=(A1′,A2′,…,Ak′) of length at least 22原创 2021-10-20 22:36:17 · 301 阅读 · 0 评论 -
ARC116C Multiple Sequences(隔板法,枚举)
ARC116C(隔板法,枚举)题目链接Problem StatementGiven are integers NNN and MMM. How many sequences AAA of NNN integers satisfy the following conditions?1≤Ai≤M(i=1,2,…,N)1 \leq A_i \leq M \left(i = 1, 2, \ldots, N\right)1≤Ai≤M(i=1,2,…,N)Ai+1A_{i+1}Ai+1 is a mul原创 2021-10-20 22:31:30 · 191 阅读 · 0 评论 -
CodeForces - 294C_Shaass and Lights(组合数学)
CodeForces - 294C_Shaass and LightsThere are nnn lights aligned in a row. These lights are numbered 1 to nnn from left to right. Initially some of the lights are switched on. Shaass wants to switch all the lights on. At each step he can switch a light on原创 2021-09-16 20:41:27 · 111 阅读 · 0 评论 -
AtCoder abc156_E_Roaming(组合数学,隔板法)
AtCoder abc156_e_RoamingProblem StatementThere is a building with n rooms, numbered 1 to n.We can move from any room to any other room in the building.Let us call the following event a move: a person in some room ii goes to another room j (iii≠\neq=$原创 2021-09-16 19:49:17 · 244 阅读 · 0 评论 -
HDU7048 Link with EQ
题目链接题目大意: 有一张桌子长度为n,第一个人是随便坐的,但是接下来坐的一个人,要尽可能的远离旁边的人,就是要求与最近距离的人靠得尽可能的远,问你长度为n的桌子能够坐的期望人数是多少?思路: 通过推几个样例,我们可以发现当第一个人坐下以后,这张桌子能够坐总人数也已经可以知道了,那么我们就是要求1n∗∑i=1nq(x)\frac {1}{n}*\sum_{i=1}^{n}q(x)n1∗∑i=1nq(x)(1n\frac{1}{n}n1为第一个人随机选择一个位置的概率,q(x)为选择x这个位原创 2021-08-24 10:03:35 · 165 阅读 · 0 评论 -
Light oj 1138 Trailing Zeroes (III) (二分)
Trailing Zeroes (III)You task is to find minimal natural number N, so that N! contains exactly Q zeroes on the trail in decimal notation. As you know N! = 1 * 2 * … * N. For example, 5! = 120, 120 contains one zero on the trail.inputInput starts with an原创 2021-03-22 16:21:52 · 76 阅读 · 0 评论 -
POJ1006 Biorhythms(暴力)
题目链接DescriptionSome people believe that there are three cycles in a person’s life that start the day he or she is born. These three cycles are the physical, emotional, and intellectual cycles, and they have periods of lengths 23, 28, and 33 days, respect原创 2020-09-12 21:43:01 · 140 阅读 · 0 评论 -
A Dangerous Maze(期望问题)
题目链接You are in a maze; seeing n doors in front of you in beginning. You can choose any door you like. The probability for choosing a door is equal for all doors.If you choose the ith door, it can either take you back to the same position where you begun原创 2020-09-11 22:29:04 · 237 阅读 · 0 评论 -
HDU1808&&POJ3370 Halloween treats(鸽巢定理)
HDU题目链接POJ题目链接Problem DescriptionEvery year there is the same problem at Halloween: Each neighbour is only willing to give a certain total number of sweets on that day, no matter how many children call on him, so it may happen that a child will get noth原创 2020-09-09 20:04:31 · 117 阅读 · 0 评论 -
HDU 5776 sum(鸽巢定理简单题)
题目链接Problem DescriptionGiven a sequence, you’re asked whether there exists a consecutive subsequence whose sum is divisible by m. output YES, otherwise output NOInputThe first line of the input has an integer T (1≤T≤10), which represents the number of原创 2020-09-08 20:23:04 · 234 阅读 · 1 评论 -
HDU 1205 吃糖果(鸽巢定理)
题目链接Problem DescriptionHOHO,终于从Speakless手上赢走了所有的糖果,是Gardon吃糖果时有个特殊的癖好,就是不喜欢将一样的糖果放在一起吃,喜欢先吃一种,下一次吃另一种,这样;可是Gardon不知道是否存在一种吃糖果的顺序使得他能把所有糖果都吃完?请你写个程序帮忙计算一下。Input第一行有一个整数T,接下来T组数据,每组数据占2行,第一行是一个整数N(0<N<=1000000),第二行是N个数,表示N种糖果的数目Mi(0<Mi<=10000原创 2020-09-07 19:31:58 · 217 阅读 · 0 评论 -
Maximum GCD(gcd)
题目链接Given the N integers, you have to find the maximum GCD (greatest common divisor) of every possible pair of these integers.InputThe first line of input is an integer N (1 < N < 100) that determines the number of test cases.The following N line原创 2020-08-29 19:39:47 · 242 阅读 · 0 评论 -
POJ2478 Farey Sequence(欧拉函数)
题目链接DescriptionThe Farey Sequence Fn for any integer n with n >= 2 is the set of irreducible rational numbers a/b with 0 < a < b <= n and gcd(a,b) = 1 arranged in increasing order. The first few areF2 = {1/2}F3 = {1/3, 1/2, 2/3}F4 = {1/4,原创 2020-08-26 22:12:35 · 189 阅读 · 0 评论 -
POJ 3070 Fibonacci(矩阵快速幂)
题目链接In the Fibonacci integer sequence, F0 = 0, F1 = 1, and Fn = Fn − 1 + Fn − 2 for n ≥ 2. For example, the first ten terms of the Fibonacci sequence are:0, 1, 1, 2, 3, 5, 8, 13, 21, 34, …An alternative formula for the Fibonacci sequence isGiven an in原创 2020-08-25 22:03:04 · 171 阅读 · 0 评论 -
菜鸡学习数论的第六天 之同余 ,费马小定理
同余 定义:如果整数a和整数b除以正整数m,则称 a ,b 摸 m 同余,记为 a ≡ b (mod m).同余类与剩余类 同余类也称剩余类。对于任意的a属于[ 0, m - 1 ],集合[ a + k * m](k属于整数)中的所有元素摸m同余,余数都是a。这个集合[ a + k * m ]称为一个模m的同余类,简记为ā。模m的同余类一定有 m 个,分别为[0],[1],[2],[3],……,[m-1]。这些同余类构成m的完全剩余系。1 ~ m 中与m互质的数代表的同余类共有φ(m原创 2020-08-24 22:50:16 · 364 阅读 · 0 评论 -
菜鸡学习数论的第五天之 最大公约数,扩展欧几里得
最大公约数与最小公倍数 若自然数d同时是自然数a和b的约数,这称d是a和b的公约数。在所有a和b的公约数中最大的一个称为a和b的最大公约数,记为gcd(a,b)。 若自然数m同时是自然数a和b的倍数,这称m是a和b的公倍数。在所有a和b的公倍数中最小的一个称为a和b的最小公倍数,记为lcm(a,b)。对于任意a,b属于自然数,gcd(a,b)*lcm(a,b)=a*b证明:设d=gcd( a , b ),a0 = a / d,b0=b/d,gcd(a0,b0)=1,lcm(a0,b0)=a0原创 2020-08-23 22:29:13 · 136 阅读 · 0 评论 -
HDU 2588 GCD(欧拉函数)
题目链接Problem DescriptionThe greatest common divisor GCD(a,b) of two positive integers a and b,sometimes written (a,b),is the largest divisor common to a and b,For example,(1,2)=1,(12,18)=6.(a,b) can be easily found by the Euclidean algorithm. Now Carp is原创 2020-08-21 21:12:34 · 148 阅读 · 0 评论 -
Goldbach`s Conjecture(素数筛)
题目链接Goldbach’s conjecture is one of the oldest unsolved problems in number theory and in all of mathematics. It states:Every even integer, greater than 2, can be expressed as the sum of two primes [1].Now your task is to check whether this conjecture ho原创 2020-08-20 20:31:28 · 178 阅读 · 0 评论 -
Aladdin and the Flying Carpet(唯一分解定理)
LightOJ - 1341 Aladdin and the Flying CarpetIt’s said that Aladdin had to solve seven mysteries before getting the Magical Lamp which summons a powerful Genie. Here we are concerned about the first mystery.Aladdin was about to enter to a magical cave, le原创 2020-08-19 21:20:04 · 271 阅读 · 0 评论 -
学习数论的第四天之逆元
逆元原创 2020-08-17 18:46:01 · 839 阅读 · 0 评论 -
POJ 3090 Visible Lattice Points
DescriptionA lattice point (x, y) in the first quadrant (x and y are integers greater than or equal to 0), other than the origin, is visible from the origin if the line from (0, 0) to (x, y) does not pass through any other lattice point. For example, the原创 2020-08-16 22:08:09 · 82 阅读 · 0 评论 -
菜鸡学习数论第三天 之 欧拉函数
质因子 质因子(质因数)是指能整除给定正整数的质数。比如说6,它的质因子是2和3。(6= 2 * 3) 质因子与因子的区别:质因子是需要能够整除给定的正整数同时它是质数。因子只要是整除给定的数,就是因子不需要是质数。欧拉函数 1~N中与N互质的数的个数被称为欧拉函数,记为Φ(N). Φ(N)=N*(p1-1)/p1*(p2-1)/p2*……(pm-1)/pm;(其中p1,p2……pm为N的所有质因数) =N*(Π(1-1/p))(累乘条件(质数p|N));(|是整除符号)证明:原创 2020-08-16 21:18:52 · 271 阅读 · 0 评论 -
菜鸡学习数论的第二天 之约数
约数 约数,也称因数。若一个整数n除以b没有余数,那么就称b是n的约数,b能够整除n,记为d|n,’|'为整除符号。一.如何求N的正约数集合 如果给你一个数N,让你去求N的约数是多少,你应该怎么求呢?我们当然可以暴力的从1到N循环一遍,然后看有多少个数能够被N整除就可以,时间复杂度为O(N),但是如果当这个N足够大的时候,这个时间肯定是很长的呢。那么我们可以想到如果 d >= 根号N,d是N的约数的话,那么必然存在 N / d <= 根号N,约数它是成对出现的,除非N为完全平方数,根号原创 2020-08-15 14:00:18 · 263 阅读 · 0 评论 -
Aladdin and the Flying Carpet(欧拉函数打表,素数的筛选)
题目链接Bamboo Pole-vault is a massively popular sport in Xzhiland. And Master Phi-shoe is a very popular coach for his success. He needs some bamboos for his students, so he asked his assistant Bi-Shoe to go to the market and buy them. Plenty of Bamboos of a原创 2020-08-10 22:39:56 · 101 阅读 · 0 评论 -
区间筛+例题(POJ2689)
区间筛 区间筛一般用于那种超大区间的素数筛选当中,例如我给你一个区间 [ l , r ],其中 l < r && r<=2 ^31, r - l<=10 ^ 6,这个时候我们已知的筛法不可能从2 ~ r去筛选,同时也不能从 l ~ r 去筛选(无法开这么大的数组,会爆)。那我们这个时候能够用什么去筛选呢?我们应该不难想到 r 中所有的合数的最小质因子一定是小于等于根号 r,那么我们可以先筛选 2 ~ 根号r 中的所有素数,然后去标记 l ~ r中所含的能够被整除2 ~原创 2020-08-10 13:43:19 · 576 阅读 · 0 评论 -
菜鸡学习数论的第一天 之 质数(判定,筛选)
一.什么是质(素)数 质(素)数就是除了1和它自身之外,不能够被其他数整除的数。二.质(素)数的判定 一般来说就是从2~n-1循环去判断是否其中有一个数能够整除n。如果有,那么n就不是质数,如果没有,n就是质数。 代码如下:#include<iostream>#include<cstdio>#include<cstring>#include<algorithm>using namespace std;bool is_prime(in原创 2020-08-09 19:12:26 · 129 阅读 · 0 评论 -
HDU 1576 A/B(扩展欧几里得)
HDU 1576Problem Description要求(A/B)%9973,但由于A很大,我们只给出n(n=A%9973)(我们给定的A必能被B整除,且gcd(B,9973) = 1)。Input数据的第一行是一个T,表示有T组数据。每组数据有两个数n(0 <= n < 9973)和B(1 <= B <= 10^9)Output对应每组数据输出(A/B)%9973。Sample Input21000 5387 123456789Sample Output原创 2020-08-05 08:54:42 · 176 阅读 · 0 评论 -
快速幂入门题之Rightmost Digit
HDU 1061Problem DescriptionGiven a positive integer N, you should output the most right digit of N^NInputThe input contains several test cases. The first line of the input is a single integer T which is the number of test cases. T test cases follow.Ea原创 2020-08-04 22:48:23 · 150 阅读 · 0 评论 -
快速幂之A sequence of numbers
HDU 2817Problem DescriptionXinlv wrote some sequences on the paper a long time ago, they might be arithmetic or geometric sequences. The numbers are not very clear now, and only the first three numbers of each sequence are recognizable. Xinlv wants to kn原创 2020-08-04 20:56:30 · 157 阅读 · 0 评论