codeforces 431 D. Random Task 组合数学】的更多相关文章

题意: 给定m,k 0 <= m <= 10^18 ,1 <= k <= 64 求一个数n,满足n+1,n+2,...n+n这n个数中,刚好有m个数的2进制表示法刚好有k个1 保证答案在10^18内 思路: 显然, 对于x,如果x+1,x+2,...,x+x有y个数有k个1 对于x+1,则x+2,x+3,...,x+x+2有k个1的数的个数 >= y 满足单调性,考虑二分: L = m,r = 10^18 那么问题变为:给定一个数x,x+1,x+2,...,x+x中刚好有k个…
D. Random Task time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output One day, after a difficult lecture a diligent student Sasha saw a graffitied desk in the classroom. She came closer and read:…
E. A Simple Task Problem's Link: http://codeforces.com/problemset/problem/558/E Mean: 给定一个字符串,有q次操作,每次操作将(l,r)内的字符升序或降序排列,输出q次操作后的字符串. analyse: 基本思想是计数排序. 所谓计数排序,是对一个元素分布较集中的数字集群进行排序的算法,时间复杂度为O(n),但使用条件很苛刻.首先对n个数扫一遍,映射出每个数字出现的次数,然后再O(n)扫一遍处理出:对于数字ai,…
题目链接:http://codeforces.com/contest/70/problem/D Once a walrus professor Plato asked his programming students to perform the following practical task. The students had to implement such a data structure that would support a convex hull on some set of…
题目链接:http://codeforces.com/contest/558/problem/E E. A Simple Task time limit per test5 seconds memory limit per test512 megabytes inputstandard input outputstandard output   This task is very simple. Given a string S of length n and q queries each qu…
codeforces 932E Team Work 题意 给定 \(n(1e9)\).\(k(5000)\).求 \(\Sigma_{x=1}^{n}C_n^xx^k\). 题解 解法一 官方题解 的做法,网上有很多,就不写了. 解法二 从组合数学的角度入手. 参考博客 我们可以这样理解这个式子 \(\Sigma_{x=1}^{n}C_n^xx^k\) :有 \(n\) 种小球,从中选出 \(x\) 种,再选出 \(k\) 个小球,这 \(k\) 个小球只能来自选定的 \(x\) 种类别.求方案…
B. Random Teams time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output n participants of the competition were split into m teams in some manner so that each team has at least one participant. Afte…
One day, after a difficult lecture a diligent student Sasha saw a graffitied desk in the classroom. She came closer and read: "Find such positive integer n, that among numbers n + 1, n + 2, ..., 2·n there are exactly m numbers which binary representa…
题目描述:  A Simple Task time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Given a simple graph, output the number of simple cycles in it. A simple cycle is a cycle with no repeated vertices or…
题面 传送门:http://codeforces.com/problemset/problem/840/C C. On the Bench time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output A year ago on the bench in public park Leha found an array of n numbers. L…