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…
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…
A. Maximum Square Ujan decided to make a new wooden roof for the house. He has…
Ujan decided to make a new wooden roof for the house. He has nn rectangular planks numbered from 11 to nn. The ii-th plank has size ai×1ai×1 (that is, the width is 11 and the height is aiai). Now, Ujan wants to make a square roof. He will first choos…
模拟即可 #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…
水题 #include <iostream> #include <vector> #include <algorithm> using namespace std; int main(){ vector<int> a(4); cin >> a[0] >> a[1]>>a[2]>>a[3]; string str; cin >> str; int res = 0; for(int i = 0 ; i…
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]产生影响…
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:…