CodeForces 701A Cards】的更多相关文章

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代码可以解释解题答案…
题目链接: A. Cards 题意: 问两个数的和相同,怎么组合; AC代码: #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <cmath> #include <bits/stdc++.h> #include <stack> using namespace std; #define For(i,j…
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/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…
瞎搞题...凭直觉+猜测写了一发,居然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;…
题目传送门: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…
E. Vladik and cards 题目链接 http://codeforces.com/contest/743/problem/E 题面 Vladik was bored on his way home and decided to play the following game. He took n cards and put them in a row in front of himself. Every card has a positive integer number not e…
MUH and House of Cards Time Limit:1000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submit Status Practice CodeForces 471C Description Polar bears Menshykov and Uslada from the zoo of St. Petersburg and elephant Horace from the zoo o…
A. Bear and Five Cards time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output A little bear Limak plays a game. He has five cards. There is one number written on each card. Each number is a posit…
B. Game of Credit Cards time limit per test:2 seconds memory limit per test:256 megabytes input:standard input output:standard output After the fourth season Sherlock and Moriary have realized the whole foolishness of the battle between them and deci…
B. Cards Sorting  http://codeforces.com/problemset/problem/830/B 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 100 000, inclusive. It is possible that some cards have the sam…
A. Bear and Five Cards 题目连接: http://www.codeforces.com/contest/680/problem/A Description A little bear Limak plays a game. He has five cards. There is one number written on each card. Each number is a positive integer. Limak can discard (throw out) s…
C. Soldier and Cards Time Limit: 20 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/546/problem/C Description Two bored soldiers are playing card war. Their card deck consists of exactly n cards, numbered from 1 to n, all values are diff…
地址:http://codeforces.com/problemset/problem/744/C 题目: C. Hongcow Buys a Deck of Cards time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output One day, Hongcow goes to the store and sees a brand ne…
链接:https://codeforces.com/contest/1173/problem/C 题意: Nauuo is a girl who loves playing cards. One day she was playing cards but found that the cards were mixed with some empty ones. There are nn cards numbered from 11 to nn, and they were mixed with…
题目链接:http://codeforces.com/contest/731/problem/F F. Video Cards time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Little Vlad is fond of popular computer game Bota-2. Recently, the developers…
题目链接:http://codeforces.com/problemset/problem/546/C 题解: 用两个队列模拟过程就可以了. 特殊的地方是:1.如果等大,那么两张牌都丢弃 : 2.如果操作了很多次仍不能分出胜负,则认为平手.(至于多少次,我也不知道,只能写大一点碰运气,但要防止超时) 代码如下: #include<iostream>//C - Soldier and Cards #include<cstdio> #include<cstring> #in…
题目传送门 /* 题意:两堆牌,每次拿出上面的牌做比较,大的一方收走两张牌,直到一方没有牌 queue容器:模拟上述过程,当次数达到最大值时判断为-1 */ #include <cstdio> #include <iostream> #include <algorithm> #include <cstring> #include <string> #include <stack> #include <cmath> #inc…
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output Two bored soldiers are playing card war. Their card deck consists of exactly n cards, numbered from 1 to n, all values are different. They divid…
链接: https://codeforces.com/contest/1215/problem/A 题意: The final match of the Berland Football Cup has been held recently. The referee has shown n yellow cards throughout the match. At the beginning of the match there were a1 players in the first team…
1 Problem Description Problem The final match of the Berland Football Cup has been held recently. The referee has shown n yellow cards throughout the match. At the beginning of the match there were a1 players in the first team and a2 players in the s…
链接: https://codeforces.com/contest/1220/problem/A 题意: When Serezha was three years old, he was given a set of cards with letters for his birthday. They were arranged into words in the way which formed the boy's mother favorite number in binary notati…
Codeforces 731 F. Video Cards 题目大意:给一组数,从中选一个数作lead,要求其他所有数减少为其倍数,再求和.问所求和的最大值. 思路:统计每个数字出现的个数,再做前缀和,用于之后快速求和.将原数组排序后去重,枚举每一个数做lead的情况下,其余数减少后再求和的结果.不断维护最大值即可. PS:这里用到了一个方便的函数unique()来去重,使用前需要先将数组排序,参数为数组的首地址和尾后地址,返回新的尾后地址.(该函数没有将重复的元素删除,只是放到了尾地址后面)可…
---恢复内容开始--- output standard output The final match of the Berland Football Cup has been held recently. The referee has shown n yellow cards throughout the match. At the beginning of the match there were a_1 players in the first team and a_2 players…
E. Vladik and cards time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Vladik was bored on his way home and decided to play the following game. He took n cards and put them in a row in front…