CodeForces - 1236B (简单组合数学)】的更多相关文章

题意 有n种物品和m个背包,每种物品有无限个,现将若干个物品放到这些背包中,满足: 1.每个背包里不能出现相同种类的物品(允许有空背包): 2.在所有的m个背包中,每种物品都出现过. 求方案数,对10^9+7取模. 思路 考虑每个物品在每个背包是否出现,那么对于物品i,有2^m中方案,然后因为在所有背包中每种物品至少要出现一次,所以要减去全不出现的方案,所以是2^m - 1,有n个物品,那么就是(2^m -1)^n 代码 #include<bits/stdc++.h> using namesp…
Last summer Peter was at his granny's in the country, when a wolf attacked sheep in the nearby forest. Now he fears to walk through the forest, to walk round the forest, even to get out of the house. He explains this not by the fear of the wolf, but…
On his free time, Chouti likes doing some housework. He has got one new task, paint some bricks in the yard. There are nn bricks lined in a row on the ground. Chouti has got mm paint buckets of different colors at hand, so he painted each brick in on…
补一下codeforces前天教育场的题.当时只A了一道题. 大致题意: 定义一个x - y - counter :是一个加法计数器.初始值为0,之后可以任意选择+x或者+y而我们由每次累加结果的最后一位生成一个数列. 例如:4 - 2 - counter 进行+4 +4 +4 +4 +2 +4操作会生成数列 04824.每步要加上x或y是任意的. 给你一个数列(由0~9组成的字符串),问你0~9中全部两个数字生成这个包含这个子串的数列中间至少要插入多少数字.以10 * 10矩阵格式输出. 例如…
Acingel is a small town. There was only one doctor here — Miss Ada. She was very friendly and nobody has ever said something bad about her, so who could've expected that Ada will be found dead in her house? Mr Gawry, world-famous detective, is appoin…
A #include <bits/stdc++.h> #define PI acos(-1.0) #define mem(a,b) memset((a),b,sizeof(a)) #define TS printf("!!!\n") #define pb push_back #define inf 1e9 //std::ios::sync_with_stdio(false); using namespace std; //priority_queue<int,vect…
Description 监狱有连续编号为1...N的N个房间,每个房间关押一个犯人,有M种宗教,每个犯人可能信仰其中一种.如果相邻房间的犯人的宗教相同,就可能发生越狱,求有多少种状态可能发生越狱 Input 输入两个整数M,N.1<=M<=10^8,1<=N<=10^12 Output 可能越狱的状态数,模100003取余 Sample Input 2 3 Sample Output 6 HINT 6种状态为(000)(001)(011)(100)(110)(111) Source…
Paths on a Grid Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 23008 Accepted: 5683 Description Imagine you are attending your math lesson at school. Once again, you are bored because your teacher tells things that you already mastered ye…
H - Benches Time Limit:500MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Submit Status Description The city park of IT City contains n east to west paths and n north to south paths. Each east to west path crosses each north to south pa…
描述 http://www.lydsy.com/JudgeOnline/problem.php?id=1008 监狱有连续编号为1...N的N个房间,每个房间关押一个犯人,有M种宗教,每个犯人可能信仰其中一种.如果 相邻房间的犯人的宗教相同,就可能发生越狱,求有多少种状态可能发生越狱. p.s.我真的没有企图概括的必要... 分析 所有情况是m^n,不可能发生越狱的情况是m*(m-1)^(n-1). 最后答案就是: m*(m^(n-1)-(m-1)^(n-1)).做个快速幂就好了. 注意: 1.…