CF 628C 题目大意:给定一个长度为n(n < 10^5)的只含小写字母的字符串,以及一个数d,定义字符的dis--dis(ch1, ch2)为两个字符之差, 两个串的dis为各个位置上字符的dis之和,求和给定的字符串的dis为d的字符串,若含有多个则输出任意一个,不存在输出-1 解题思路:简单贪心,按顺序往后,对每一个字符,将其变为与它dis最大的字符(a或者z),d再减去相应的dis, 一直减到d为0,剩余的字母则不变直接输出.若一直到最后一位d仍然大于0,则说明不存在,输出-1. /…
C. Bear and String Distance 题目连接: http://www.codeforces.com/contest/628/problem/C Description Limak is a little polar bear. He likes nice strings - strings of length n, consisting of lowercase English letters only. The distance between two letters is…
C. Bear and String Distance time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Limak is a little polar bear. He likes nice strings - strings of length n, consisting of lowercase English letter…
C. Bear and String Distance time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Limak is a little polar bear. He likes nice strings — strings of length n, consisting of lowercase English letter…
题目大意:原题链接 相邻两个字母如果不同,则可以结合为前一个字母,如ac可结合为a.现给定一个字符串,问结合后最短可以剩下多少个字符串 解体思路:简单贪心 一开始读题时,就联想到之前做过的一道题,从后往前贪心(关键),假设dp[i]表示从第i个字符开始到末尾结合后最短可以剩下的字符串数目. 然后拿笔在纸上画了画,发现果然是正确的.最后只要输出dp[0]即可. 好开心,从读题到AC总共不超过10分钟,傻逼了,刚开始误写为dp[sz-1]=0; #include<bits/stdc++.h> us…
Uva 11729  Commando War (简单贪心) There is a war and it doesn't look very promising for your country. Now it's time to act. You have a commando squad at your disposal and planning an ambush on an important enemy camp located nearby. You have N soldiers…
发工资咯: Time Limit: 2000/1000ms (Java/Others) Problem Description: 作为广财大的老师,最盼望的日子就是每月的8号了,因为这一天是发工资的日子,养家糊口就靠它了,呵呵 但是对于学校财务处的工作人员来说,这一天则是很忙碌的一天,财务处的小胡老师最近就在考虑一个问题:如果每个老师的工资额都知道,最少需要准备多少张人民币,才能在给每位老师发工资的时候都不用老师找零呢? 这里假设老师的工资都是正整数,单位元,人民币一共有100元.50元.10元…
Ruin of Titanic Time Limit: 2000/1000ms (Java/Others) Problem Description: 看完Titanic后,小G做了一个梦.梦见当泰坦尼克号撞到冰山时,自己也在大船上.情况十分危急,不过这个时候船才刚进水,距离船身完全沉没还有一定时间(假如救生的船足够的话可以顺利逃生). 假设大船上共有n个人,每个人的重量为W1,W2,....,Wn;现在有若干小船,每一只船最大载重为100,且每一艘小船规定最多只能载2人.你能帮焦急的船长算出最少…
http://acm.hdu.edu.cn/showproblem.php?pid=1516 Problem Description String Distance is a non-negative integer that measures the distance between two strings. Here we give the definition. A transform list is a list of string, where each string, except…
New Year is coming, and Jaehyun decided to read many books during 2015, unlike this year. He has n books numbered by integers from 1 to n. The weight of the i-th (1 ≤ i ≤ n) book is wi. As Jaehyun's house is not large enough to have a bookshelf, he k…