Live2d Test Env

随笔分类 -  数学--容斥定理

摘要:题意:给定N个数a[],现在用a形成一个新的数组b[],1<=b[i]<=a[i]。 问所有的方案的最大值之和。 思路:先排序。然后分段统计贡献,假设a[i-1]<a[i],那么[a[i-1]+1,a[i]]的贡献就是左边的所有方案*右边的合法方案,合法即是最大值这个区间内。 假设max=x,那么右 阅读全文
posted @ 2019-09-03 20:02 nimphy 阅读(247) 评论(0) 推荐(0) 编辑
摘要:题意:硬币购物一共有4种硬币。面值分别为c1,c2,c3,c4。某人去商店买东西,去了tot次。每次带di枚ci硬币,买si的价值的东西。请问每次有多少种付款方法。 思路:这么老的题,居然今天才做到...背包的复杂度是比较高的。 加上tot次询问会爆炸。能不能预处理,然后容斥得到答案呢? 先求一个完 阅读全文
posted @ 2019-08-08 11:23 nimphy 阅读(286) 评论(0) 推荐(0) 编辑
摘要:pro: T次询问,每次给出N(N<1e8),求所有Σi^4 (i<=N,且gcd(i,N)==1) ; sol: 因为N比较小,我们可以求出素因子,然后容斥。 主要问题就是求1到P的4次幂和。 我们知道K次幂和是一个K+1次多项式。 这里有公式Pre=P*(P+1)*(2P+1)*(3P^2+3P 阅读全文
posted @ 2019-06-05 18:28 nimphy 阅读(216) 评论(0) 推荐(0) 编辑
摘要:A .Jzzhu and Chocolate pro:现在给定一个大小为N*M的巧克力,让你横着或者竖着切K刀,都是切的整数大小,而且不能切在相同的地方,求最大化其中最小的块。 (N,M,K<1e9) sol:如果横着切X刀,竖着切Y刀,那么最小的面积=(N/(X+1))*(M/(Y+1));一看这 阅读全文
posted @ 2019-03-01 22:22 nimphy 阅读(341) 评论(0) 推荐(0) 编辑
摘要:As everyone known, The Monkey King is Son Goku. He and his offspring live in Mountain of Flowers and Fruits. One day, his sons get n peaches. And ther 阅读全文
posted @ 2019-02-27 11:41 nimphy 阅读(357) 评论(0) 推荐(0) 编辑
摘要:(本套题算是比较温和吧,就是罚时有点高。 B .Baby Bites 题意:给出一个婴儿给出的数组,有一些数字听不清楚,让你还原,问它是否是一个从1开始的一次增加的数组。 思路:从左往右依次固定,看是否有矛盾即可。 #include<bits/stdc++.h> #define ll long lo 阅读全文
posted @ 2019-02-01 17:06 nimphy 阅读(634) 评论(1) 推荐(0) 编辑
摘要:Alex decided to try his luck in TV shows. He once went to the quiz named "What's That Word?!". After perfectly answering the questions "How is a pseud 阅读全文
posted @ 2019-01-07 13:05 nimphy 阅读(261) 评论(0) 推荐(0) 编辑
摘要:Permutation p is an ordered set of integers p1, p2, ..., pn, consisting of n distinct positive integers, each of them doesn't exceed n. We'll denote t 阅读全文
posted @ 2018-12-20 17:11 nimphy 阅读(348) 评论(0) 推荐(0) 编辑
摘要:In an attempt to make peace with the Mischievious Mess Makers, Bessie and Farmer John are planning to plant some flower gardens to complement the lush 阅读全文
posted @ 2018-12-20 15:35 nimphy 阅读(439) 评论(0) 推荐(0) 编辑
摘要:4833: [Lydsy1704月赛]最小公倍佩尔数 Description 令(1+sqrt(2))^n=e(n)+f(n)*sqrt(2),其中e(n),f(n)都是整数,显然有(1-sqrt(2))^n=e(n)-f(n)*sqrt(2)。令g( n)表示f(1),f(2)…f(n)的最小公倍 阅读全文
posted @ 2018-11-17 18:33 nimphy 阅读(356) 评论(0) 推荐(0) 编辑
摘要:Description 刚开始你有一个数字0,每一秒钟你会随机选择一个[0,2^n-1]的数字,与你手上的数字进行或(c++,c的|,pascal 的or)操作。选择数字i的概率是p[i]。保证0<=p[i]<=1,Σp[i]=1问期望多少秒后,你手上的数字变成2^n-1。 刚开始你有一个数字0,每 阅读全文
posted @ 2018-11-12 16:03 nimphy 阅读(290) 评论(0) 推荐(0) 编辑
摘要:In your childhood, do you crazy for collecting the beautiful cards in the snacks? They said that, for example, if you collect all the 108 people in th 阅读全文
posted @ 2018-11-10 15:24 nimphy 阅读(415) 评论(0) 推荐(0) 编辑
摘要:Given you a sequence of number a 1, a 2, ..., a n, which is a permutation of 1...n. You need to answer some queries, each with the following format: G 阅读全文
posted @ 2018-11-05 15:35 nimphy 阅读(322) 评论(0) 推荐(0) 编辑
摘要:题意:T组数据,给次给出N,M,K,多少种方案,用[0,N-1]范围的数,表示一个M排列,其和为K; 思路:隔板法,不限制[0,N-1]的时候答案是C(M+K-1,M-1);那么我们减去至少一个>=N,加上至少两个>=N....即可得到答案。 假设至少一个隔板里的数大于大于N,我们从这个隔板里抽出N 阅读全文
posted @ 2018-11-01 11:11 nimphy 阅读(175) 评论(0) 推荐(0) 编辑
摘要:一个包含四个点的完全图,可以在任意节点出发,可以在任意节点结束,给出每个点被经过的次数,求有多少种合法的遍历序列。如果两个序列至少有一位是不同的,则认为它们不相同。 Input Sample Output 题意:给a个A,b个B,c个C,d个D,求有少种排列,使得相邻的两个不同。 思路:用容斥来做, 阅读全文
posted @ 2018-10-30 18:40 nimphy 阅读(336) 评论(0) 推荐(0) 编辑
摘要:【BZOJ3622】已经没有什么好害怕的了 Description Input Output Sample Input 4 2 5 35 15 45 40 20 10 30 Sample Output 4 HINT 输入的2*n个数字保证全不相同。 输入的2*n个数字保证全不相同。 题意:给定a数组 阅读全文
posted @ 2018-10-25 17:30 nimphy 阅读(325) 评论(0) 推荐(0) 编辑
摘要:Let's call a non-empty sequence of positive integers a1, a2... ak coprime if the greatest common divisor of all elements of this sequence is equal to  阅读全文
posted @ 2018-09-13 09:14 nimphy 阅读(420) 评论(0) 推荐(0) 编辑
摘要:Count the number of distinct sequences a1, a2, ..., an (1 ≤ ai) consisting of positive integers such that gcd(a1, a2, ..., an) = x and . As this numbe 阅读全文
posted @ 2018-09-07 16:22 nimphy 阅读(338) 评论(1) 推荐(0) 编辑
摘要:有n个数字,a11,a22,…,ann。有一个集合,刚开始集合为空。然后有一种操作每次向集合中加入一个数字或者删除一个数字。每次操作给出一个下标x(1 ≤ x ≤ n),如果axx已经在集合中,那么就删除axx,否则就加入axx。 问每次操作之后集合中互质的数字有多少对。 注意,集合中可以有重复的数 阅读全文
posted @ 2018-06-05 18:34 nimphy 阅读(688) 评论(0) 推荐(0) 编辑
摘要:Devu wants to decorate his garden with flowers. He has purchased n boxes, where the i-th box contains fi flowers. All flowers in a single box are of t 阅读全文
posted @ 2018-03-15 20:42 nimphy 阅读(540) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示