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

php中文网
发布: 2016-06-24 12:04:04
原创
1454人浏览过

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的卡路里,给出踩白块的序列,问要消耗多少卡路里。

分析: 
模拟水题..

代码:

div+css3阶梯分页样式
div+css3阶梯分页样式

div+css3阶梯分页样式

div+css3阶梯分页样式 84
查看详情 div+css3阶梯分页样式

立即学习前端免费学习笔记(深入)”;

/**  Author:      illuz <iilluzen[at]gmail.com>*  File:        a.cpp*  Create Date: 2014-05-21 23:33:25*  Descripton:   */#include <cstdio>#include <iostream>#include <string>using namespace std;int a[5], ans;string s;int main(){	for (int i = 1; i <= 4; i++)		cin >> a[i];	cin >> s;	for (int i = 0; i < s.length(); i++)		ans += a[s[i] - '0'];	cout << ans << endl;	return 0;}
登录后复制


B - Shower Line

题目地址

题意: 
5个学生排队,某一个排队方式的每一个情况下,第2i-1个人和第2个人会交谈。交谈时,第i和第j个人的交谈会产生g[i][j] + g[j][i]的欢乐(搞基)值,求中最大的欢乐值。

分析: 
刚开始还以为人数没定,犹豫了一会... 
直接用next_permutation暴力,5!是可以接受的。

代码:

立即学习前端免费学习笔记(深入)”;

/**  Author:      illuz <iilluzen[at]gmail.com>*  File:        b.cpp*  Create Date: 2014-05-21 23:43:23*  Descripton:   */#include <cstdio>#include <iostream>#include <algorithm>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 < 5; i++)		for (int j = 0; j < 5; j++)			scanf("%d", &g[i][j]);	for (int i = 0; i < 5; i++)		for (int j = i + 1; j < 5; j++) {			g[j][i] = g[i][j] = g[i][j] + g[j][i];		}	do {		mmax = max(mmax, g[a[0]][a[1]] + g[a[1]][a[2]] + g[a[2]][a[3]] * 2 + g[a[3]][a[4]] * 2);	} while (next_permutation(a, a + 5));	cout << mmax << endl;	return 0;}
登录后复制


C - k-Tree

题目地址

题意: 
一颗无限的k-tree,定义如下: 
每个节点都有k个分支,第i个分支的边的权值为i。 
问在k-tree中有多少条路径,里面至少有一条边权值不小于d,且路径边的和为n。

分析: 
比赛时没敲出来(太弱orz),赛后发现有个地方错了... 
这题可以用dp,因为是无限的树,所以根节点下来和每个节点下来是一样的,但是转移为子问题还需要一个因素,就是条件限定边必须 具体看代码...

代码:

立即学习前端免费学习笔记(深入)”;

/**  Author:      illuz <iilluzen[at]gmail.com>*  File:        c.cpp*  Create Date: 2014-05-22 00:20:28*  Descripton:   */#include <cstdio>#include <cstring>#include <iostream>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 <= min(r, k); i++)		if (b || 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 << dp(n, 0) << endl;	return 0;}
登录后复制


HTML速学教程(入门课程)
HTML速学教程(入门课程)

HTML怎么学习?HTML怎么入门?HTML在哪学?HTML怎么学才快?不用担心,这里为大家提供了HTML速学教程(入门课程),有需要的小伙伴保存下载就能学习啦!

下载
来源:php中文网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
开源免费商场系统广告
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号