D. Random Task time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output One day, after a difficult lecture a diligent student Sasha saw a graffitied desk in the classroom. She came closer and read:…
Codeforces Round #247 (Div. 2) http://codeforces.com/contest/431  代码均已投放:https://github.com/illuz/WayToACM/tree/master/CodeForces/431 A - Black Square 题目地址 题意:  Jury玩别踩白块,游戏中有四个区域,Jury点每一个区域要消耗ai的卡路里,给出踩白块的序列,问要消耗多少卡路里. 分析:  模拟水题.. 代码: /* * Author: i…
http://codeforces.com/contest/478/problem/B B. Random Teams time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output n participants of the competition were split into m teams in some manner so that…
B. Random Teams   n participants of the competition were split into m teams in some manner so that each team has at least one participant. After the competition each pair of participants from the same team became friends. Your task is to write a prog…
B. Shower Line time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Many students live in a dormitory. A dormitory is a whole new world of funny amusements and possibilities but it does have its…
模拟即可 #include <iostream> #include <vector> #include <algorithm> using namespace std; int main(){ vector<); ; i < ; ++ i) a[i] = i; ][]; ; i < ; ++ i){ ; j < ; ++ j){ cin >> g[i][j]; } } ; do{ maxHappiness = max(g[a[]][a…
A.水题. 遍历字符串对所给的对应数字求和即可. B.简单题. 对5个编号全排列,然后计算每种情况的高兴度,取最大值. C.dp. 设dp[n][is]表示对于k-trees边和等于n时,如果is==1表示存在边至少为d的边,如果is==0表示不存在边至少为d的边. 初始状态dp[0][0]=1. //和为n且不存在至少为d的边的状态可以由所有不存在至少为d的边加一条小于d的边转移而来. dp[n][0]=dp[n-1][0]+dp[n-2][0]+……+dp[n-(d-1)][0] //和为n…
赛后想了想,然后就过了.. 赛后....... 我真的很弱啊!想那么多干嘛? 明明知道这题的原型就是求求排列数,这不就是 (F[N]-B[N]+100000007)%100000007: F[N]是1-K组成N的方案数,B[N]是1-d-1组成N的个数 . 想想就不开心,昨天一晚没睡好+今天上午的课都在睡觉....哭死 DP要搞起,各种基础都不会…
题目链接 自己的dp, 不是很好,这道dp题是 完全自己做出来的,完全没看题解,还是有点进步,虽然这个dp题比较简单. 题意:一个k叉树, 每一个对应权值1-k, 问最后相加权值为n, 且最大值至少为d 的路径有多少条. 思路:d[i][l][sum] 表示第i 行最大值为l, 总和为sum的路径数. 注意:我的代码中 sum + j 有可能会超过数组最大值,即越界,刚开始我以为不会产生影响,后来 发现不知道为什么 在数组里越界以后比如 越界到d[][][111] 会对 d[][][1]产生影响…
A. Black Square time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Quite recently, a very smart student named Jury decided that lectures are boring, so he downloaded a game called "Black Squar…