2012年8月19日

Letter Grid(动规)

摘要: Consider the following letter grid:ERATATSRAUTUThere are 7 ways to read the word TARTU from the grid:ERATATSRAUTUERATATSRAUTUERATATSRAUTUERATATSRAUTUERATATSRAUTUERATATSRAUTUERATATSRAUTUGiven a letter grid and a word, your task is to determine the number of ways the word can be read from the grid. Th 阅读全文

posted @ 2012-08-19 19:54 yumao 阅读(208) 评论(0) 推荐(0)

删数问题

摘要: 给你一个N位数,从中去掉K个数字,能得到的最大的数是多少?INPUT有T测试数据,每组测试数据第一行由N和K2个整数组成(1 ≤ K < N ≤ 500 000),第二行是N位数(非0开头)。OUTPUT对每组数据输出去掉K个数字得到的最大数。SAMPLE TESTSINOUT34 219247 3123123410 44177252841943234775841贪心思想: 从头遍历k次,每次遇到不递减的数字,就将其删除掉,并结束该次循环。每次循环都如上所做。 其中如果遇到从头到尾一直都是递减的,则删除最后一个数字。代码实现:#include<iostream>#includ 阅读全文

posted @ 2012-08-19 19:40 yumao 阅读(183) 评论(0) 推荐(0)

导航