codeforces #364a Cards】的更多相关文章

cf的a题没什么好说到,100的量级,每个人给2张牌,使每个人手中的牌点数相等.保证有一种分配方案. 对每个人,先计算出手中的牌的点数,然后循环两遍拿牌就可以.   A. Cards time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output There are n cards (n is even) in the deck. Each c…
B. Cards time limit per test:2 seconds memory limit per test:256 megabytes input:standard input output:standard output Catherine has a deck of n cards, each of which is either red, green, or blue. As long as there are at least two cards left, she can…
原题地址:http://codeforces.com/problemset/problem/364/A 题目大意: 给定一个数字a(0 ≤ a ≤ 109)和一个数列s(每个数都是一位,长度不超过4000),定义一个矩阵Mij = si * sj ,求M有多少个子矩阵上面的数字和恰巧等于a 算法分析: 这道题是Codeforces Round #213 Div 1 Problem A && Div 2 Problem C,赛场上没写对,主要是没分析清楚,有一点想法就迫不及待地提交,结果白白…
题目链接:http://codeforces.com/problemset/problem/999/F 题目大意:有n个人,n*k张卡牌,每个人会发到k张卡牌,每个人都有一种喜欢的卡牌f[i],当一个人拥有x张喜欢的卡牌时会增加h[x]点愉悦值,求合理的发牌方式使得所有人的愉悦值之和最大,输出最大愉悦值.解题思路:设dp[x][y]表示当x个人拥有同一种喜欢的卡牌且该卡牌有y张时的最大愉悦值.则状态转移的根本取决于第x个人拥有几张喜欢的卡牌,所以得到状态转移方程:for (int i = 0;…
B. Cards Sorting time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Vasily has a deck of cards consisting of n cards. There is an integer on each of the cards, this integer is between 1 and 10…
A. Cards time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output There are n cards (n is even) in the deck. Each card has a positive integer written on it. n / 2 people will play new card game. At…
直接看示例输入输出+提示 1. 统计所有数的和 sum,然后求 sum/(n/2) 的到一半数的平均值 6 1 5 7 4 4 3 ->1+5+7+4+4+3=24  分成3组 每组值为8 int sumavg=sum/(n/2)=8 2. int z=sumavg-x[i] if(x[j]==z&&!dp[i]&&!dp[j]) //如果当前数为该输出的数,且i,j没有输出过,则输出 i,j (数组下标), 且dp[i]=dp[j]=1; AC代码可以解释解题答案…
瞎搞题...凭直觉+猜测写了一发,居然AC了.. #include<cstdio> #include<cstring> #include<cmath> #include<string> #include<vector> #include<queue> #include<algorithm> #include<iostream> using namespace std; +]; int n; int R,G,B;…
[链接] 我是链接,点我呀:) [题意] 让你求出b[i][j]=s[i]*s[j]规则构成的矩阵 的所有子矩阵中子矩阵的和为a的子矩阵的个数 [题解] (x,y,z,t) 会发现它的和就是sum(x,y)sum(z,t) sum(x,y)=a[x]+a[x+1]+...+a[y] 因为这个子矩阵的和就是 a[x][z]+a[x][z+1]+...+a[x][t] + a[x+1][z] + a[x+1][z+1]....+a[x+1][t] .... 而a[i][j] = a[i]a[j] 下…
题目传送门:CF1278F. 题意简述: 有 \(n\) 个独立随机变量 \(x_i\),每个随机变量都有 \(p = 1/m\) 的概率取 \(1\),有 \((1-p)\) 的概率取 \(0\). 令 \(\displaystyle \Sigma x = \sum_{i=1}^{n} x_i\),求 \(E({(\Sigma x)}^k)\). 题解: \[ \begin{aligned} \mathbf{Ans} &= \sum_{i=0}^{n} \binom{n}{i} p^i (1-…