Codeforces 263B. Appleman and Card Game】的更多相关文章

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/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…
是一道简单题 将字母从个数多到小排序 然后 再按题目算法得到最多 但是注意 数据类型声明 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…
题目链接:Codeforces 461B Appleman and Tree 题目大意:一棵树,以0节点为根节点,给定每一个节点的父亲节点,以及每一个点的颜色(0表示白色,1表示黑色),切断这棵树的k条边,使得树变成k+1个联通分量.保证每一个联通分量有且仅有1个黑色节点.问有多少种切割方法. 解题思路:树形dp,dp[i][0]和dp[i][1]分别表示子树一下的切割方法中,i节点所在联通块不存在黑节点和已经存在一个黑节点的方案数. #include <cstdio> #include &l…
题目链接:http://codeforces.com/problemset/problem/461/A 题目意思:给出一群由 n 个数组成的集合你,依次循环执行两种操作: (1)每次Toastman得到一个集合,他计算所有数的和,并且将它加入到score里.之后他将这个集合传给Appleman. (2)Appleman得到的集合如果只有一个数,就把它弃之,否则将这个集合分成 两个不相交且不空的集合,传回给Toastman. 这些操作不断执行直到集合个数变为0,也就是通过使集合都变成只有一个元素而…
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…
B. Appleman and Tree time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Appleman has a tree with n vertices. Some of the vertices (at least one) are colored black and other vertices are color…
http://codeforces.com/problemset/problem/461/B 思路:dp,dp[i][0]代表这个联通块没有黑点的方案数,dp[i][1]代表有一个黑点的方案数 转移:首先如果儿子节点是个有黑点的,父亲节点也有黑点,那么只能分裂开,不能合并在一起,只对dp[u][1]有贡献 如果儿子节点是个有黑点的,父亲节点没有黑点,那么可以分裂也可以合并,对dp[u][1]和dp[u][0]都有贡献 如果儿子节点是个没有黑点的,父亲节点有黑点,那么必须和父亲合并,对dp[u][…
题目链接:http://codeforces.com/contest/461/problem/B 题目大意: 给定一课树,树上的节点有黑的也有白的,有这样一种分割树的方案,分割后每个子图只含有一个黑色节点,问这样的分割方案一共有多少种? 分析: 先定义3个函数(为了之后说起来方便): 设A(x) = 在以顶点x为根的子树中,所有满足使x所在子图不含黑色顶点,其余子图只含有1个黑色顶点的分割方案种数 . 设B(x) = 在以顶点x为根的子树中,所有满足每个子图只含有1个黑色顶点的分割方案种数 .…
题目链接:http://codeforces.com/problemset/problem/461/B 题意: 给你一棵树(编号从0到n-1,0为根节点),每个节点有黑白两种颜色,其中黑色节点有k+1个. 现在让你删掉k条边,使得这棵树变成k+1个连通块,并且要保证每个连通块中有且仅有一个黑色节点. 问你删边的方案有多少种. 题解: 表示状态: dp[i][0/1] = numbers 表示在节点i所在的连通块中有(1)或没有(0)黑色节点时,节点i的子树的删边方法数 因为总要保证每个连通块中有…
A. Appleman and Easy Task time limit per test  1 second memory limit per test  256 megabytes input  standard input output  standard output Toastman came up with a very easy task. He gives it to Appleman, but Appleman doesn't know how to solve it. Can…
[题目链接]: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..到第…
C. Appleman and Toastman time limit per test  2 seconds memory limit per test  256 megabytes input  standard input output  standard output Appleman and Toastman play a game. Initially Appleman gives one group of nnumbers to the Toastman, then they st…
刚刚看到这个题感觉是博弈题: 不过有感觉不像,应该是个贪心: 于是就想贪心策略: 举了一个例子: 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…
题目链接 Fill a DP table such as the following bottom-up: DP[v][0] = the number of ways that the subtree rooted at vertex v has no black vertex. DP[v][1] = the number of ways that the subtree rooted at vertex v has one black vertex. The recursion pseudo…
一棵树上有K个黑色节点,剩余节点都为白色,将其划分成K个子树,使得每棵树上都仅仅有1个黑色节点,共同拥有多少种划分方案. 个人感觉这题比較难. 如果dp(i,0..1)代表的是以i为根节点的子树种有0..1个黑色节点的划分方案数. 当节点i为白色时.对于它的每一个孩子的节点处理: 求dp(i, 0)时有: 1,将该节点与孩子节点相连,但要保证孩子节点所在的子树种没有黑色节点: 2,将该节点不与该孩子节点相连.则该孩子节点要保证所在子树种有黑色节点: 即dp(i, 0) = π(dp(j,0 )…
原文链接https://www.cnblogs.com/zhouzhendong/p/CF461D.html 题解 首先我们可以发现如果确定了第一行,那么方案就唯一了. 然后,我们来看看一个点的值确定了会导致什么: 假设我们确定了红色点的值,那么所有包含橙色的格子xor起来就等于红色格子的值,绿色蓝色也是. 第一排就比较特殊了. 如果我们在对第一排奇偶分类之后,如果我们可以得到第一行的前缀xor之间的关系,那么我们就有希望解决这个问题. 再看一种情况: 类似地意思,我们会发现这个东西遇到墙会反射…
比赛链接:http://codeforces.com/contest/462 这次比赛的时候,刚刚注冊的时候非常想好好的做一下,可是网上喝了个小酒之后.也就迷迷糊糊地看了题目,做了几题.一觉醒来发现rating掉了非常多,那个心痛啊! 只是.后来认真的读了题目,发现这次的div2并非非常难! 官方题解:http://codeforces.com/blog/entry/13568 A. Appleman and Easy Task 解析:         一个水题,推断每一个细胞周围是否都是有偶数…
题目链接 A. Appleman and Easy Task time limit per test:2 secondsmemory limit per test:256 megabytesinput:standard inputoutput:standard output Toastman came up with a very easy task. He gives it to Appleman, but Appleman doesn't know how to solve it. Can…
题目: 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…
Appleman and Card Game Time Limit: 2000/1000ms (Java/Others) Problem Description: 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…
Appleman and Card Game Time Limit:1000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submit Status Practice CodeForces 462B Description Appleman has n cards. Each card has an uppercase letter written on it. Toastman must choose k card…
http://codeforces.com/contest/462 A:Appleman and Easy Task 要求是否全部的字符都挨着偶数个'o' #include <cstdio> using namespace std; ][]; int n; ][]; ]={,,-,}; ]={,-,,}; int main(){ scanf("%d",&n); gets(maz[]); ;i<n;i++){ gets(maz[i]); } ;i<n;i+…
昨天没打,今天写了一下,前三题都没有难度吧. A. Appleman and Easy Task time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Toastman came up with a very easy task. He gives it to Appleman, but Appleman doesn't know h…
Squares CodeForces - 263B Vasya has found a piece of paper with a coordinate system written on it. There are ndistinct squares drawn in this coordinate system. Let's number the squares with integers from 1 to n. It turned out that points with coordin…
A - Score UVA - 1585 水 #include<bits/stdc++.h> using namespace std; int main(){ int n; cin>>n; while(n--){ ; string s; cin>>s; int len=s.size(); ; ;i<len;i++){ if(s[i]=='O')sum+=tmp,tmp++; else { sum+=tmp; tmp=; } } sum+=tmp; cout<…
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…
题目传送门 /* 贪心:每次把一个丢掉,选择最小的.累加求和,重复n-1次 */ /************************************************ Author :Running_Time Created Time :2015-8-1 13:20:01 File Name :A.cpp *************************************************/ #include <cstdio> #include <algori…
题目链接 D. Appleman and Tree time limit per test :2 seconds memory limit per test: 256 megabytes input :standard input output:standard output Appleman has a tree with n vertices. Some of the vertices (at least one) are colored black and other vertices a…