Codeforces 808F. Card Game】的更多相关文章

题目大意 一个物品有三个属性 : 价值,键值,等级. 你不能选取等级高于\(level\)的物品,键值之和为质数的两个数字不共存. 问最低的等级使得可以选出价值之和超过\(k\)的物品. \(n\leq 100, 1 \leq \text{键值} \leq n\) 题解 首先考虑二分答案. 这样可以去掉物品等级的限制. 我们很容易发现除了\(2\)的所有偶数都是非质数. 什么意思呢 ? 如果我们不考虑\(1\)这个神奇的数字,那么按照排斥关系建边会发现这构成了一张二分图. 所以可以直接用最小割经…
F - Card Game 思路: 题意: 有n张卡片,每张卡片三个值,pi,ci,li: 要求选出几张卡片使得pi之和大于等于给定值: 同时,任意两两ci之和不得为素数: 求选出的li的最小值,如果不能到达给定值则输出-1: 二分+网络流最小割: 代码: #include <bits/stdc++.h> namespace data { #define maxn 105 #define maxque 200005 int val[maxn],mag[maxn],lev[maxn],num,l…
Digital collectible card games have become very popular recently. So Vova decided to try one of these. Vova has n cards in his collection. Each of these cards is characterised by its power pi, magic number ci and level li. Vova wants to build a deck…
设dp[i][j]表示选到了第i张牌,牌号在j之前包括j的概率,cnt[i]表示有i张牌,inv[i]表示i在mod下的逆元,那我们可以考虑转移,dp[i][j]=dp[i-1][j-1]*cnt[j]*inv[n-i+1],这个只是表示当前成功转移到i j的状态,如果要考虑胜利的条件,显然是选在选一次j即可赢取胜率,那么对于答案ans只需要加上dp[i-1][j-1]*cnt[j]*inv[n-i+1]*(cnt[j]-1)*inv[n-i]即可,因为我们这个dp[i][j]是记录j之前所有的…
题目链接:http://codeforces.com/problemset/problem/462/B Appleman has n cards. Each card has an uppercase letter written on it. Toastman must choose k cards from Appleman's cards. Then Appleman should give Toastman some coins depending on the chosen cards…
codeforces 893D Credit Card 题目大意: 有一张信用卡可以使用,每天白天都可以去给卡充钱.到了晚上,进入银行对卡的操作时间,操作有三种: 1.\(a_i>0\) 银行会给卡充入\(a_i\)元 2.\(a_i<0\) 银行从卡中扣除\(a_i\)元 3.\(a_i=0\) 银行对你的卡进行评估,违背了规则就无权再使用此卡 规则1:卡内的余额不得超过\(d\)元 规则2:当\(a_i=0\)时,卡内的余额不能是负数 现在问为了维持信用的平衡,最少去银行几次.(去一次,充…
C. Fox and Card Game 题目连接: http://codeforces.com/contest/388/problem/C Description Fox Ciel is playing a card game with her friend Fox Jiro. There are n piles of cards on the table. And there is a positive integer on each card. The players take turns…
Codeforces Round #228 (Div. 1) 题目链接:C. Fox and Card Game Fox Ciel is playing a card game with her friend Fox Jiro. There are n piles of cards on the table. And there is a positive integer on each card. The players take turns and Ciel takes the first…
题目链接http://codeforces.com/contest/106/problem/A 题意:一套牌有S.H.D.C四种花色,按等级分成6.7.8.9.T.J.Q.K.A.每次选出一个花色作为无敌的花色(属于这个花色的牌可以打败所有不属于这个花色的牌,无视等级). 第一张牌打败第二张牌的情况有: 1.第一张牌是无敌的花色,第二张牌不是 2.第一张牌和第二张牌的花色相同,并且第一张牌的等级高于第二张牌 其余的所有情况均视为第一张牌不能打败第二张牌(包括第一张牌的花色不同于第二张牌且第一张牌…
D - Travel Card 思路:dp,类似于单调队列优化. 其实可以写的更简单... #include<bits/stdc++.h> #define LL long long #define fi first #define se second #define mk make_pair #define pii pair<int, int> using namespace std; ; ; const int inf = 0x3f3f3f3f; const LL INF = 0…
水dp,加个二分就行,自己看代码. B. Travel Card time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output A new innovative ticketing systems for public transport is introduced in Bytesburg. Now there is a single t…
D. Credit Card time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Recenlty Luba got a credit card and started to use it. Let's consider n consecutive days Luba uses the card. She starts with …
B. Appleman and Card Game time limit per test  1 second memory limit per test  256 megabytes input  standard input output  standard output Appleman has n cards. Each card has an uppercase letter written on it. Toastman must choose k cards from Applem…
[题目链接]:http://codeforces.com/contest/760/problem/D [题意] 去旅行,有3种类型的乘车票; 第一种:只能旅行一次20元 第二种:按时间计算,90分钟内能无限量旅行,50元 第三种:按时间计算,1440分钟内能无限量旅行,120元 每次旅行只消耗一分钟; 给你n次旅行开始的时间(顺序); 让你求出第1到第i次旅行的这些旅行最少需要花费多少钱f[i]; (每次都重新计算) 输出f[i]-f[i-1]; [题解] 动态规划; 设f[i]表示第1..到第…
Credit Card time limit per test2 seconds memory limit per test256 megabytes Recenlty Luba got a credit card and started to use it. Let's consider n consecutive days Luba uses the card. She starts with 0 money on her account. In the evening of i-th da…
刚刚看到这个题感觉是博弈题: 不过有感觉不像,应该是个贪心: 于是就想贪心策略: 举了一个例子: 3 3 1 2 3 4 3 4 1 2 5 4 1 2 5 8 如果他们两个每次都拿对自己最有利的那个的话,C的得分是14分: 但是C作为第一个选手,他有更好的策略,只拿前一半,后一半给J,中间的再分:这样的话C的得分就能达到15分: 同样J也有这样的策略,他也能保证自己最少能拿到后一半的分(跟风式的拿): 这样的话,贪心策略就明朗了! #include<cstdio> #include<c…
大意: 给定序列, 求多少个区间积被k整除. 整除信息满足单调性, 显然双指针. 具体实现只需要考虑k的素数向量, 对每一维维护个指针即可. 这题看了下cf其他人的做法, 发现可以直接暴力, 若当前的前缀积模k为0, 暴力向前求出第一个后缀积为0的位置即可, 复杂度是$O(n)$的并且相当好写. #include <iostream> #include <algorithm> #include <cstdio> #include <math.h> #incl…
题意: Recenlty Luba有一张信用卡,一开始金额为0,每天早上可以充值任意数量的钱,但有限制,卡里的钱不能超过D.到了晚上,银行会对信用卡进行一次操作,操作有三种: 1.a[i]>0,.充入a[i]元. 2..a[i]<0 .扣除a[i]元. 3..a[i]=0 查询卡里的金额. 若干在a[i]=0时,卡里的钱为负的或者某天卡里的钱>D,则卡将被冻结,问Recenlty Luba至少需要去银行存多少次钱,使得在接下来的n天里,银行卡不会被冻结. 思路: 贪心,当a[i]=0时,…
是一道简单题 将字母从个数多到小排序 然后 再按题目算法得到最多 但是注意 数据类型声明 money要为long long #include <iostream> #include <stdio.h> #include <string.h> #include <algorithm> using namespace std; ]; ];//因为 虽然 n是到10^5但是有money和money相乘 的操作 再存储在同一位置 就超了 int n, k; bool…
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 最大值出现次数是偶数. 那么就取次大值. 次大值也是偶数? =>再次 因为你绝对不能取偶数个的. 取了对方就总是能面对一个奇数的情况了. 则对面总是能拿走最后一个了. [代码] #include <bits/stdc++.h> using namespace std; const int N = 1e5; int n,a[N+10]; int main(){ #ifdef LOCAL_DEFINE freopen(&qu…
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 每次遇到0的时候,看看当前累计的delta是多少. 如果大于0,则temp = d-delta; 小于0,取temp2 = min(d-max{delta}(这里max指之前一段0和0之间的区域),temp); 然后delta显然可以直接加上temp2,可以保证在0和0之间不会超过d. 然后看看delta是不是大于等于0了. 是的话,temp = delta,否则delta=inf,ans++; 然后不论如何delta都直接变成…
题目链接:http://codeforces.com/contest/493/problem/A 题目意思:给出两个字符串,分别代表 home 和 away.然后有 t 个player,每个player偶四个属性描述:分钟,所属的队名(即上面的两个字符串的其中一个),该player的num,得到的card颜色(y/r). 当一个人得到两个y card 时会自动转为 r card.最终需要按时间先后的顺序输出player第一次获得red card 的时间. 由于数据是按时间先后顺序排列的,那么对于…
A. Bear and Five Cards 题目链接:http://codeforces.com/contest/680/problem/A 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) some cards. His go…
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…
题目链接:http://codeforces.com/problemset/problem/471/C 题目意思:有 n 张卡,问能做成多少种不同楼层(floor)的 house,注意这 n 张卡都要用光.每层 floor 都由一定的 room 构成,每两个相邻 room 规定要有一个公共的ceiling.规定从上到下看,每层 floor 的 room 的数量呈递增的形式排布. 好容易想到构成最高层时用的最少数量的card需要多少.可以发现,每层的需要用到的card 可以用这个表达式表示: 3n…
J. Deck Shuffling Time Limit: 2   Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100187/problem/J Description The world famous scientist Innokentiy continues his innovative experiments with decks of cards. Now he has a deck of n cards and k…
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…
A. Sereja and Dima time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Sereja and Dima play a game. The rules of the game are very simple. The players have n cards in a row. Each card contains…
题目链接:http://codeforces.com/contest/493 A. Vasya and Football Vasya has started watching football games. He has learned that for some fouls the players receive yellow cards, and for some fouls they receive red cards. A player who receives the second y…