F. Selection of Personnel time limit per test 0.5 seconds memory limit per test 64 megabytes input standard input output standard output One company of IT City decided to create a group of innovative developments consisting from 5 to 7 people and hir…
<题目链接> 题目大意: 给出a和b,如果一个数每一位都是a或b,那么我们称这个数为good,在good的基础上,如果这个数的每一位之和也是good,那么这个数是excellent.求长度为n的excellent数的个数mod(1e9+7). 解题分析: 我们可以枚举a的个数m,所以b的个数为(n-m),然后判断这种情况是否可行,即,是否满足a*m+b*(n-m)为good number ,如果满足的话,则答案加上C(n,m).因为n很大,并且在计算组合数的过程中,需要除以很大的数,所以需要求…
C. Iahub and Permutations time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Iahub is so happy about inventing bubble sort graphs that he's staying all day long at the office and writing permu…
按tutorial打的我血崩,死活挂第四组- - 思路来自FXXL /* CodeForces 837F - Prefix Sums [ 二分,组合数 ] | Educational Codeforces Round 26 题意: 设定数组 y = f(x) 使得 y[i] = sum(x[j]) (0 <= j < i) 求初始数组 A0 经过多少次 f(x) 后 会有一个元素 大于 k 分析: 考虑 A0 = {1, 0, 0, 0} A1 = {1, 1, 1, 1} -> {C(…
A. Again Twenty Five! time limit per test 0.5 seconds memory limit per test 64 megabytes input standard input output standard output The HR manager was disappointed again. The last applicant failed the interview the same way as 24 previous ones. "Do…
题目链接:http://codeforces.com/gym/100548/attachments 有n个物品 m种颜色,要求你只用k种颜色,且相邻物品的颜色不能相同,问你有多少种方案. 从m种颜色选k种颜色有C(m, k)种方案,对于k种颜色方案为k*(k-1)^(n-1)种.但是C(m, k)*k*(k-1)^(n-1)方案包括了选k-1,k-2...,2种方案. 题目要求刚好k种颜色,所以这里想到用容斥. 但是要是直接C(m, k)*k*(k-1)^(n-1) - C(m, k-1)*(k…
D. Selection Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100114 Description When selecting files in an application dialog, Vasya noted that he can get the same selection in different ways. A simple mouse click selects a sing…
题目链接:http://codeforces.com/contest/837/problem/F 题意:如题QAQ 解法:参考题解博客:http://www.cnblogs.com/FxxL/p/7282909.html    由于新生成的m+1个数列第一个肯定为0,所以可以忽略掉,当作每次新生成的数列只拥有m个元素    来枚举一个例子,可以发现规律. 当a[] = {1,0,0,0,0}时,手动推出的矩阵如下: 可以发现对于这个矩阵显然是满足杨辉三角的,我们二分出一个值后可以直接利用组合数来…
题目链接:http://codeforces.com/problemset/problem/893/E 题意: 共q组数据(q <= 10^5),每组数据给定x,y(x,y <= 10^6). 问你有多少种长度为y,乘积为x的整数数列.(可以有负数) 题解: 首先考虑数列只有正整数的情况. 将x分解质因数:x = ∑ a[i]*p[i] 由于x较大,所以要先用线性筛求出素数,再枚举素数分解质因数. 那么一个乘积为x的数列可以看做,将x的所有∑ p[i]个质因子,分配到了y个位置上. 设f(i)…
题目链接:http://codeforces.com/problemset/problem/869/C 题意: 红色.蓝色.紫色的小岛分别有a,b,c个. 你可以在两个不同的岛之间架桥,桥的长度为1. 任意两个颜色相同的岛之间的距离不能小于3. 问你合法的架桥方案数. 题解: 显然只能在不同颜色的岛之间连边. 而且一个岛对于一种颜色,最多只能连一个岛. 设f(x,y)表示两种颜色的岛相互连边,分别有x,y个,连边的方案数.(x < y) 那么ans = f(a,b) * f(b,c) * f(a…