CodeForces 626B Cards】的更多相关文章

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…
瞎搞题...凭直觉+猜测写了一发,居然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;…
题目链接: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…
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…
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代码可以解释解题答案…
题目传送门: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-…
将每个数字的位置存进该数字的vector中 原数组排个序从小到大处理,每次在vector里二分找到距离当前位置“最远”的位置(相差最大),更新答案 树状数组维护每个数字现在的位置和原位置之差 #include <bits/stdc++.h> using namespace std; #define LL long long ; int n; int a[N], b[N]; vector<int> v[N]; int c[N]; void modify(int x, int num)…
传送门 解题过程: \(答案=\sum^n_{i=0}*C^i_n*{\frac{1}{m}}^i*{\frac{m-1}{m}}^{n-i}*i^k\) 根据第二类斯特林数的性质\(n^k=\sum^k_{i=0}S^i_k*i!*C^i_n=\sum^k_{i=0}S^i_k*n^\underline{i}\)将普通幂转为下降幂 \(=\sum^n_{i=0}C^i_n*{\frac{1}{m}}^i*{\frac{m-1}{m}}^{n-i}\sum^k_{j=0}S^j_k*i^\und…