题目链接:hdu 4722 Good Numbers
题目大意:给出a,b,问从a到b之间,有多少个好数字,好数字的定义为:每个位的数字相加是10的倍数。
解题思路:dp[i][j]表示第i位,前i-1位的和为j(j可以从200简化成10,以为只需要考虑最后的数是否是10的倍数即可)有多少个数,需要注意的就是恰好为b的情况,所以要有一个跟踪值s。
#include
...
分类:
其他好文 时间:
2014-05-10 09:46:45
阅读次数:
232
这道题还挺复杂的,回来看了好一会儿才想起当时怎么想的。。上道题刚说不要打表,这道题就用了打表。。
总的思路是这样的,从后面往前面打表,最后一个位置的最小分割一定是0,那往前呢,如果当前考虑的位置是start,并且substr(s, i)是回文的,那么如果已知i+1开始的分割次数,那么start这个位置的分割应该就是start原来的和i+1开始的分割次数加1之间的最小值。DP的思想,很直接。
但...
分类:
其他好文 时间:
2014-05-07 07:37:39
阅读次数:
307
The Little Elephant likes permutations. This time he has a permutation A[1], A[2], ..., A[N] of numbers 1, 2, ...,N.
He calls a permutation A good, if the number of its inversions is equal to the n...
分类:
其他好文 时间:
2014-05-07 07:20:50
阅读次数:
356
[Question]
Given an array of integers, find two numbers such that they add up to a specific target number.
The function twoSum should return indices of the two numbers such that they add up to t...
分类:
其他好文 时间:
2014-05-07 05:37:44
阅读次数:
278
题目链接: SCUT 2014
题目大意: 判断给出的字符串中是否是正确的科学计数法
A+1.5Be+8C,可以是实数或者含有指数的实数,ABC三个部分表示空格,可有可无,正负号可有可无
指数部分只能是整数
解题思路: 建立有穷自动机状态转移表,一共是10种状态...
分类:
其他好文 时间:
2014-05-07 05:32:27
阅读次数:
330
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4722
思路:数位dp,dp[i][j]表示到第i位,数字和%10为j,然后进行dp,注意完全匹配的情况是要+1,而其他情况是从0 到 9 都要考虑
代码:
#include
#include
#include
#include
using namespace std;
int t;
l...
分类:
其他好文 时间:
2014-05-07 04:55:37
阅读次数:
314
Subtraction Game 1
Chef is playing a game on a sequence of N positive integers, say A1, A2, ... AN. The game is played as follows.
If all the numbers are equal, the game ends.Otherwise
Sele...
分类:
其他好文 时间:
2014-05-07 03:14:01
阅读次数:
280
Given a triangle, find the minimum path sum
from top to bottom. Each step you may move to adjacent numbers on the row
below.For example, given the fol...
分类:
其他好文 时间:
2014-05-07 02:55:24
阅读次数:
377
Problem:The sequence of triangle numbers is
generated by adding the natural numbers. So the 7thtriangle number would be 1 +
2 + 3 + 4 + 5 + 6 + 7 = 28...
分类:
其他好文 时间:
2014-05-07 00:28:01
阅读次数:
365
尝试用两头分别比较的方法,结果发现无法解决1000021这种问题 1 public class
Solution { 2 public boolean isPalindrome(int x) { 3 if(x= 10) { 6 div *= 10;
7...
分类:
其他好文 时间:
2014-05-06 10:39:40
阅读次数:
241