随笔分类 -  计数

摘要:Recall that the permutation is an array consisting of nn distinct integers from 11 to nn in arbitrary order. For example, [2,3,1,5,4][2,3,1,5,4] is a 阅读全文
posted @ 2020-05-03 23:21 DeaL57 阅读(156) 评论(0) 推荐(0)
摘要:You are given two integers nn and mm. Calculate the number of pairs of arrays (a,b)(a,b) such that: the length of both arrays is equal to mm; each ele 阅读全文
posted @ 2020-04-28 21:20 DeaL57 阅读(189) 评论(0) 推荐(0)
摘要:Recall that MEX of an array is a minimum non-negative integer that does not belong to the array. Examples: for the array [0,0,1,0,2][0,0,1,0,2] MEX eq 阅读全文
posted @ 2020-04-27 10:55 DeaL57 阅读(200) 评论(0) 推荐(0)
摘要:You are given string ss of length nn consisting of 0-s and 1-s. You build an infinite string tt as a concatenation of an infinite number of strings ss 阅读全文
posted @ 2020-04-26 22:24 DeaL57 阅读(151) 评论(0) 推荐(0)
摘要:考虑全为0的串数。我们有m个1,相当于有m+1的空隙可以用来放0。那么显然我们把这n-m个0匀着放到这m+1个空隙,可以使得每个0的部分尽可能短,进而使得全为0的子串尽可能少。 所以每个空隙放b=(n-m)/(m+1)。因为不能整除,所有有(n-m) % (m+1)个空隙实际上还要再多一个0。 如果 阅读全文
posted @ 2020-04-26 11:18 DeaL57 阅读(126) 评论(0) 推荐(0)
摘要:VK news recommendation system daily selects interesting publications of one of nn disjoint categories for each user. Each publication belongs to exact 阅读全文
posted @ 2020-04-26 00:23 DeaL57 阅读(212) 评论(0) 推荐(0)
摘要:Your task is to calculate the number of arrays such that: each array contains nn elements; each element is an integer from 11 to mm; for each array, t 阅读全文
posted @ 2020-04-25 10:22 DeaL57 阅读(171) 评论(0) 推荐(0)
摘要:Constanze is the smartest girl in her village but she has bad eyesight. One day, she was able to invent an incredible machine! When you pronounce lett 阅读全文
posted @ 2020-02-29 18:00 DeaL57 阅读(262) 评论(0) 推荐(0)