POJ 3390 题意 把n个单词排版 每行最多m个字符 不同单词间有空格 每行最后一个单词后没空格 空格占一个字符 当一行的字符数与m的差为t时 就会扣t*t分 求最少扣分
令a[i]表示第i个单词的长度 s[i]表示从第一个单词到第i个单词单词长度和d[i]表示前i个单词排版后最少扣的分
则t=m-(s[i] - s[j] + i - j - 1)表示把从第j+1个单词到第i个单词放在一行时这行的字符长度与m的差
那么当t>=0时 有转移方程 d[i]=min(d[i],d...
分类:
其他好文 时间:
2014-08-01 19:55:12
阅读次数:
249
一 Words 1 nevertheless 然而,不过 breathtaking激动人心的,惊险的,惊人的 eg. He nevertheless completed the film with breathtaking speed.但他还是以惊人的速度拍完了这部电影 2 folk 人们,亲人n,...
分类:
其他好文 时间:
2014-08-01 13:05:31
阅读次数:
247
Description:Given an input string, reverse the string word by word.For example,Given s = "the sky is blue",return "blue is sky the".Clarification:What...
分类:
其他好文 时间:
2014-08-01 04:38:31
阅读次数:
183
一 Words 1 shade 遮蔽,逐渐变成v eg. As the dusk shaded into night,we drove slowly through narrow alleys.夜幕渐渐降临,我们驱车在狭窄的胡同里缓慢前行。 阴凉处,细微差别n eg.the capacity to ...
分类:
其他好文 时间:
2014-07-31 20:14:57
阅读次数:
188
#!/bin/bash#文件名:checkword.shword=$1grep "^$1$" /usr/share/dict/linux.words -qif [ $? -eq 0 ];then echo $word is a dictionary word;else e...
分类:
其他好文 时间:
2014-07-30 17:10:13
阅读次数:
180
题目链接题意 : 有很多门,每个门上有很多磁盘,每个盘上一个单词,必须重新排列磁盘使得每个单词的第一个字母与前一个单词的最后一个字母相同。给你一组单词问能不能排成上述形式。思路 :把每个单词看成有首字母指向尾字母的有向边,每个字母看成一个点,题中要求等效于判断图中是否存在一条路径经过每一条一次且仅一...
分类:
其他好文 时间:
2014-07-30 11:54:33
阅读次数:
229
一 Words 1 foible 小缺点,小癖好 e.g. You could do Ebay,or dating or indulge 纵容,沉溺于another foible of choice.你可以上eBay购物,或者约会,或者纵容另外一个弱点。 2 obnoxious 讨厌的 eg. My...
分类:
其他好文 时间:
2014-07-30 07:39:03
阅读次数:
274
考虑几个特殊的情况1.若字符窜s=" "2.字符窜s=“a b d e”3.字符窜s=“ a”然后在s后面+上一个‘ ’,每次遇到s[i]为空格,s[i-1]不为空格的时候为一个单词class Solution{public: void reverseWords(string &s) ...
分类:
其他好文 时间:
2014-07-30 07:38:43
阅读次数:
171
题目:Given a string s and a dictionary of words dict, add spaces in s to construct a sentence where each word is a valid dictionary word.Return all suc....
分类:
编程语言 时间:
2014-07-30 03:19:32
阅读次数:
341
问题描述:
Given an input string, reverse the string word by word.
For example,
Given s = "the sky is blue",
return "blue is sky the".
解题思路:
每遍历出一个单词时,将该单词添加一个空格字符(如果临时字符串为空,即扫描出第一个单词,就不要添加空格字符),然后添加...
分类:
其他好文 时间:
2014-07-29 21:52:52
阅读次数:
239