Codeforces Round #117 (Div. 2)
Codeforces Round #117 (Div. 2)
代码
A. Battlefield
any trench in meters numerically does not exceed b.
- 这个条件意味着每次都是在蓄能开始时走向下一条线段,也就是说每条线段相当于花费了\(a+b\)的时间。
- bfs,用\(d_i\)表示到达线段i需要经过最少的线段条数,到达\(B\)的时候直接计算欧几里得距离。
B. Vasya's Calendar
- \[ans = \sum_{i=1}^{n-1}{d-a_i}\]
C. Optimal Sum
- 考虑去掉绝对值符号。
- 假定最后和为非负数,那么\(k\)次操作将前\(k\)小的负数转化成整数。
- 将长度为\(len\)的窗口\([l,r]\)逐渐往右移,优先队列维护绝对值大的负数。
- 弹出\(a[r-len]\)时,判断该位置是否有变号。
- 加入\(a[r]\)时,如果是负数,需要考虑是否变号,有两种情况:
- 操作次数仍有剩余,那么显然直接变号。
- 否则,考虑之前变号的负数绝对值最小的那个,是否小于\(|a[r]|\)而进行替换。
- 若最后和为负数,将\(a_i\)取反后再做一次即可。
D. Common Divisors
- kmp求出所有循环串的长度。
- 假设循环串长度为\(L\), 判断\(s[0..L]=t[0..L]\)。
E. Wooden Fence
- \(f(i,j,k)\)表示长度为\(i\),最后一块类型为\(j\),旋转状态为\(k\)的方案数。
Codeforces Round #117 (Div. 2)的更多相关文章
- Codeforces Round #117 (Div. 2) D.Common Divisors(KMP最小循环节)
http://codeforces.com/problemset/problem/182/D 题意:如果把字符串a重复m次可以得到字符串b,那么我们称字符串a为字符串b的一个因子,现在给定两个字符串S ...
- Educational Codeforces Round 117 (Rated for Div. 2)
Educational Codeforces Round 117 (Rated for Div. 2) A. Distance https://codeforces.com/contest/1612/ ...
- Codeforces Round #366 (Div. 2) ABC
Codeforces Round #366 (Div. 2) A I hate that I love that I hate it水题 #I hate that I love that I hate ...
- Codeforces Round #354 (Div. 2) ABCD
Codeforces Round #354 (Div. 2) Problems # Name A Nicholas and Permutation standard input/out ...
- Codeforces Round #368 (Div. 2)
直达–>Codeforces Round #368 (Div. 2) A Brain’s Photos 给你一个NxM的矩阵,一个字母代表一种颜色,如果有”C”,”M”,”Y”三种中任意一种就输 ...
- cf之路,1,Codeforces Round #345 (Div. 2)
cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅..... ...
- Codeforces Round #279 (Div. 2) ABCDE
Codeforces Round #279 (Div. 2) 做得我都变绿了! Problems # Name A Team Olympiad standard input/outpu ...
- Codeforces Round #262 (Div. 2) 1003
Codeforces Round #262 (Div. 2) 1003 C. Present time limit per test 2 seconds memory limit per test 2 ...
- Codeforces Round #262 (Div. 2) 1004
Codeforces Round #262 (Div. 2) 1004 D. Little Victor and Set time limit per test 1 second memory lim ...
随机推荐
- 网络安全之PHP安全编程建议
要提供互联网服务,当你在开发代码的时候必须时刻保持安全意识.可能大部分 PHP 脚本都对安全问题都不在意,这很大程度上是因为有大量的 无经验程序员 在使用这门语言.但是,没有理由让你因为对你的代码的不 ...
- centos下安装node js
#wget http://nodejs.org/dist/v0.10.24/node-v0.10.24.tar.gz #tar xf node-v0.10.24.tar.gz #cd node-v0. ...
- c#图像处理入门(-bitmap类和图像像素值获取方法) 转
一.Bitmap类 Bitmap对象封装了GDI+中的一个位图,此位图由图形图像及其属性的像素数据组成.因此Bitmap是用于处理由像素数据定义的图像的对象.该类的主要方法和属性如下: 1. GetP ...
- color 的一些处理
1.UIImage转换成UIcolor cell.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@" ...
- (转)深入理解javascript的function
原文:http://www.cnblogs.com/sharpxiajun/archive/2011/09/16/2179323.html javascript笔记:深入理解javascript的fu ...
- Java中的blank final
Java allows the creation of blank finals, which are fields that are declared as final but are not gi ...
- 如何将内存图像数据封装成QImage
http://blog.csdn.net/lyc_daniel/article/details/9055787 当采用Qt开发相机数据采集软件时,势必会遇到采集内存图像并进行处理(如缩放.旋转)操作. ...
- Emacs+highlight-parentheses高亮括号
EmacsWiki上关于它的介绍HighlightParentheses,下载最新版请通过作者的GitHub:https://github.com/nschum/highlight-parenthes ...
- BZOJ 1853 幸运数字
需要优化一波常数. 以及刚才那个版本是错的. #include<iostream> #include<cstdio> #include<cstring> #incl ...
- HDU 4971 (最小割)
Problem A simple brute force problem (HDU 4971) 题目大意 有n个项目和m个问题,完成每个项目有对应收入,解决每个问题需要对应花费,给出每个项目需解决的问 ...