随笔分类 - ACM-贪心
摘要:套题链接:http://codeforces.com/contest/732 B题Cormen The Best Friend Of a Man贪心的考虑一下,只要相邻两位之和不小于k即可。 1 #include <iostream> 2 #include <cstdio> 3 #include <
阅读全文
摘要:C.Hidden Word 链接:http://codeforces.com/contest/725/problem/C 昨天打比赛时没弄清楚题意,不过现在对题意还有怀疑,You’re given a string s which consists of 27 upper-case English
阅读全文
摘要:D. Recover the String time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output For each string s c
阅读全文
摘要:HDU 5573 Binary Tree 获得姿势:要构造数,想到用二进制构造。 一直向最左路构造,最左路的和是(2^k)-1,加入给定n,那么被减去的数字是d = (2^k)-1-n. 当我要减去一个数字时,从上往下走,对于总和相当于减去二倍的数字,所以要d/2.但前提是保证d为偶数。即为奇数时d
阅读全文
摘要:题目链接:HDU 5719 Arrange 昨天的B题,昨天做的时候没注意所有谷堆是全排列,看了Clarification才知道,可是不会做。 实际上只需要将自己的代码改动一步就可以了count = count*(c[i]-b[i]-i+2)%mod,也即c[i]-b[i]+1-(i-1) 看这个样
阅读全文
摘要:题目链接:USACO 1.3.2 这道题有点小坑,不是算法错了,而是文件名,是barn1不是barnl,恕我眼拙,找了十五分钟... 肯定是木板的个数用的越多越好,这样可以减少空隙. 简单的贪心,将每两个马厩之间的空隙从大到小排序,取前m个. 注意c<=m的情况.
阅读全文
摘要:题目链接:USACO 1.3.1 简单的贪心,将cent从小到大排序.
阅读全文
摘要:D. Bear and Two Paths time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output D. Bear and Two Pa
阅读全文