您好,欢迎访问一九零五行业门户网

Codeforces Round #247 (Div. 2) ABC_html/css_WEB-ITnose

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: illuz * file: a.cpp* create date: 2014-05-21 23:33:25* descripton: */#include #include #include using namespace std;int a[5], ans;string s;int main(){ for (int i = 1; i > a[i]; cin >> s; for (int i = 0; i
b - shower line 题目地址
题意: 
5个学生排队,某一个排队方式的每一个情况下,第2i-1个人和第2个人会交谈。交谈时,第i和第j个人的交谈会产生g[i][j] + g[j][i]的欢乐(搞基)值,求中最大的欢乐值。
分析: 
刚开始还以为人数没定,犹豫了一会... 
直接用next_permutation暴力,5!是可以接受的。
代码:
/** author: illuz * file: b.cpp* create date: 2014-05-21 23:43:23* descripton: */#include #include #include using namespace std;const int n = 5;char ch;int g[n][n], mmax;int a[5] = {0, 1, 2, 3, 4};int main(){ int i = 0, j = 0; for (int i = 0; i
c - k-tree 题目地址
题意: 
一颗无限的k-tree,定义如下: 
每个节点都有k个分支,第i个分支的边的权值为i。 
问在k-tree中有多少条路径,里面至少有一条边权值不小于d,且路径边的和为n。
分析: 
比赛时没敲出来(太弱orz),赛后发现有个地方错了... 
这题可以用dp,因为是无限的树,所以根节点下来和每个节点下来是一样的,但是转移为子问题还需要一个因素,就是条件限定边必须 具体看代码...
代码:
/** author: illuz * file: c.cpp* create date: 2014-05-22 00:20:28* descripton: */#include #include #include using namespace std;typedef long long ll;const int n = 110;const int mod = 1e9 + 7;ll d[n][2];int n, d, k;ll dp(int r, bool b){ if (d[r][b] != -1) return d[r][b]; if (r == 0) return d[r][b] = b; d[r][b] = 0; for (int i = 1; i = d) d[r][b] = (d[r][b] + dp(r - i, 1)) % mod; else d[r][b] = (d[r][b] + dp(r - i, 0)) % mod; return d[r][b];}int main(){ memset(d, -1, sizeof(d)); scanf(%d%d%d, &n, &k, &d); cout

其它类似信息

推荐信息