组合数
文章平均质量分 66
tomjobs
别慌,慌也没用
展开
-
2021年度训练联盟热身训练赛第一场 G. Birthday Paradox(生日问题,组合推公式,概率)
题意:mmm个人过生日,然后出现了nnn个不同的生日组,第一组有a1a_1a1个人,第二组有a2a_2a2个人…第nnn组有ana_nan个人。求这种情况出现的概率。思路:就是推公式概率题。总的方案数为365m365^m365m。先找出这nnn种生日,方案数为C(365,n)C(365,n)C(365,n)。然后对着mmm个人分组,也就是C(m,a1)∗C(m−a1,a2)∗...∗C(m−a1−a2...−an−1,an)C(m,a_1)*C(m-a_1,a_2)*...*C(m-a_.原创 2021-03-11 09:52:17 · 278 阅读 · 0 评论 -
K - Number with Bachelors Gym - 102835K(数位DP,不出现重复数字的排列,第k数问题)
题意:合法数字定义是不出现重复数字的数。有10进制的询问和16进制的询问,询问第k个合法数字或者[a,b][a,b][a,b]之间有多少个合法数字。思路:写的很麻的一道题,但其实很思路很简单。10进制和16进制是一样的,转换一下就好了。考虑[a,b][a,b][a,b]内多少个合法数字,我们定义dp[i][j]dp[i][j]dp[i][j]代表数字选到了第iii位,并且已经选择数字的状态为jjj(二进制状态,1代表选择了这一个数字,0代表没选择这一个数字)。数位DP算一下就得出[a,b][a原创 2020-11-29 14:51:24 · 482 阅读 · 0 评论 -
GYM J - Non Super Boring Substring Gym - 101864J(回文,组合)
题意:求问多少个子串中存在长度大于等于kkk的回文子串。思路:因为长度大于kkk的回文串,一定包含长度为kkk或者k+1k+1k+1的回文子串,所以只需要考虑长度为kkk和k+1k+1k+1的回文子串。然后对每个左端点确定有多少个匹配的右端点即可。#include <bits/stdc++.h>using namespace std;const int maxn = 1e5+10;const int mod1 = 1e9 + 7;const int mod2 = 1e9 + 9;原创 2020-11-19 14:59:46 · 254 阅读 · 0 评论 -
Codeforces 1445D. Divide and Sum(组合数学)
You are given an array ???? of length 2????. Consider a partition of array ???? into two subsequences ???? and ???? of length ???? each (each element of array ???? should be in exactly one subsequence: either in ???? or in ????).Let’s sort ???? in non-dec原创 2020-11-06 00:08:24 · 254 阅读 · 0 评论 -
2020 CCPC绵阳7-12 Lottery(组合数学,二进制)
题意:2a[i]2^{a[i]}2a[i]有nnn个,问能组合出多少种数字。思路:如果前i−1i-1i−1个数的总和大于2a[i]2^{a[i]}2a[i],那就把前iii个2b2^b2b合起来算结果。最后总的结果就是每一段的乘积。不妨设a[i]=2i−1a[i]=2^{i-1}a[i]=2i−1,则对于连续一段数1 j1~j1 j,每次考虑仅选择前iii个数,后面的数都先不用。第iii个数为2a[i]2^{a[i]}2a[i],有b[i]b[i]b[i]个。对于前i−1i.原创 2020-11-05 23:26:16 · 388 阅读 · 0 评论 -
Codeforces1436 C. Binary Search(二分,组合数)
Andrey thinks he is truly a successful developer, but in reality he didn’t know about the binary search algorithm until recently. After reading some literature Andrey understood that this algorithm allows to quickly find a certain number ???? in an array.原创 2020-10-29 21:13:28 · 236 阅读 · 0 评论 -
Codeforces1420 D. Rescue Nibel!(区间,组合数)
Ori and Sein have overcome many difficult challenges. They finally lit the Shrouded Lantern and found Gumon Seal, the key to the Forlorn Ruins. When they tried to open the door to the ruins… nothing happened.Ori was very surprised, but Sein gave the expla原创 2020-09-25 13:25:12 · 815 阅读 · 0 评论 -
牛客IOI周赛18-提高组 山脉(组合数,插板法)
链接:https://ac.nowcoder.com/acm/contest/7225/C来源:牛客网题目描述牛能来到了 “小荷山”,他发现这里的山脉海拔与坐标存在一个规律。考虑山脉的每一座山的坐标在一条直线上,我们用数轴来表示山脉的坐标。这些山脉的海拔大小都在一个范围之内,我们定义海拔最高的山为 “尖” 。这个特殊的规律可以表示为:对于 “尖” 的左侧山脉,从左到右山脉的海拔大小呈不下降;对于 “尖” 的右侧山脉,从右到左山脉的海拔大小呈不下降。而对于所有满足此规律的山脉定义为 “神奇风景”原创 2020-09-18 18:22:29 · 200 阅读 · 0 评论 -
Codeforces 1391 C. Cyclic Permutations(组合数,推公式)
A permutation of length ???? is an array consisting of ???? distinct integers from 1 to ???? in arbitrary order. For example, [2,3,1,5,4] is a permutation, but [1,2,2] is not a permutation (2 appears twice in the array) and [1,3,4] is also not a permutatio原创 2020-08-10 23:08:07 · 396 阅读 · 0 评论 -
F - Beautiful Numbers CodeForces - 300C(组合数)
Vitaly is a very weird man. He’s got two favorite digits a and b. Vitaly calls a positive integer good, if the decimal representation of this integer only contains digits a and b. Vitaly calls a good number excellent, if the sum of its digits is a good num原创 2020-08-07 00:08:24 · 259 阅读 · 0 评论 -
2020杭电多校第五场 Set2(DP,组合数学)
Problem DescriptionYou are given a set S={1…n}. You have to do the following operations until there are no more than k elements left in the S:Firstly, delete the smallest element of S, and then randomly delete another k elements one by one from the eleme原创 2020-08-05 19:20:27 · 329 阅读 · 0 评论 -
2020杭电多校第五场 Paperfolding(折纸,组合数学)
Problem DescriptionThere is a piece of paper in rectangular shape with sufficient length and width (lay flat on the table). Execute an operation instruction according to a string of length n from left to right that only contains 4 different characters of原创 2020-08-05 13:45:48 · 397 阅读 · 0 评论 -
2020杭电多校第五场 Set1(组合数学,概率)
Problem DescriptionYou are given a set S={1…n}. It guarantees that n is odd. You have to do the following operations until there is only 1 element in the set:Firstly, delete the smallest element of S. Then randomly delete another element from S.For each原创 2020-08-05 13:32:11 · 533 阅读 · 2 评论 -
2020杭电多校第三场 Little W and Contest(并查集,组合数学)
Problem DescriptionThere are n members in our ACM club. Little W wants to select three persons from our club to form a new team taking part in provincial ACM contests, as it is known by all of us that any ACM contest requires a normal team to have three m原创 2020-07-29 14:55:42 · 334 阅读 · 0 评论 -
牛客IOI周赛17-普及组 数列统计(组合数)
链接:https://ac.nowcoder.com/acm/contest/5881/D来源:牛客网题目描述求以xx结尾的长度为ll的不下降正整数数列一共有多少个。对911451407911451407取模输入描述:\textbf{本题有多组数据。}本题有多组数据。第一行一个正整数TT,表示数据组数。对于每组数据:两个用空格隔开的整数l, xl,x。输出描述:TT行,每行一个答案。示例1输入复制22 12 3输出复制13备注:对于前10%10%的数据,T = 10原创 2020-06-05 22:11:54 · 1836 阅读 · 0 评论 -
String Mark CodeForces - 895D(组合数学)
At the Byteland State University marks are strings of the same length. Mark x is considered better than y if string y is lexicographically smaller than x.Recently at the BSU was an important test work on which Vasya recived the mark a. It is very hard for原创 2020-05-22 00:55:26 · 357 阅读 · 0 评论 -
Ralph And His Magic Field CodeForces - 894B(组合数,dp转递推)
Ralph has a magic field which is divided into n × m blocks. That is to say, there are n rows and m columns on the field. Ralph can put an integer in each block. However, the magic field doesn’t always...原创 2019-09-07 19:50:44 · 210 阅读 · 0 评论 -
P3048 [USACO12FEB]牛的IDCow IDs(模拟 / 组合数)
题目描述Being a secret computer geek, Farmer John labels all of his cows with binary numbers. However, he is a bit superstitious, and only labels cows with binary numbers that have exactly K “1” bits (1 ...原创 2019-08-31 23:10:04 · 291 阅读 · 0 评论 -
Round B 2020 - Kick Start 2020(概率)
ProblemJemma is competing in a robotics competition. The challenge for today is to build a robot that can navigate around a hole in the arena.The arena is a grid of squares containing W columns (num...原创 2020-04-19 17:07:09 · 319 阅读 · 0 评论 -
ACWING212. 计数交换(组合数)
给定一个 1~n 的排列 p1,p2,…,pn,可进行若干次操作,每次选择两个整数 x,y,交换 px,py。设把 p1,p2,…,pn 变成单调递增的排列 1,2,…,n 至少需要 m 次交换。求有多少种操作方法可以只用 m 次交换达到上述目标。因为结果可能很大,你只需要输出结果对 109+9 取模之后的值。例如排列 2,3,1 至少需要2次交换才能变为 1,2,3。操作方法共有3种,分...原创 2020-03-13 20:01:30 · 302 阅读 · 0 评论 -
CCPC2019哈尔滨 Interesting Permutation Gym - 102394I(组合数学 / 推公式)
DreamGrid has an interesting permutation of 1,2,…,n denoted by a1,a2,…,an. He generates three sequences f, g and h, all of length n, according to the permutation a in the way described below:For each...原创 2020-02-14 00:01:39 · 453 阅读 · 0 评论 -
CF1228E. Another Filling the Grid(容斥原理+排列组合)
You have ????×???? square grid and an integer ????. Put an integer in each cell while satisfying the conditions below.All numbers in the grid should be between 1 and ???? inclusive.Minimum number of the ????-th ro...原创 2019-10-01 12:43:31 · 565 阅读 · 0 评论