^

Young Anything I do that may help others, I'll post it here.

hihocoder 1399 - shortening sequence

1 描述

There is an integer array A1, A2 …AN. Each round you may choose two adjacent integers. If their sum is an odd number, the two adjacent integers can be deleted.

Can you work out the minimum length of the final array after elaborate deletions?

...
more »

hihocoder 1288 — font size

1 描述

Steven loves reading book on his phone. The book he reads now consists of N paragraphs and the i-th paragraph contains ai characters.

Steven wants to make the characters easier to read, so he decides to increase the font size of characters. But the size of Steven’s phone screen is limited. Its width is W and height is H. As a result, if the font size of characters is S then it can only show ⌊W / S⌋ characters in a line and ⌊H / S⌋ lines in a page. (⌊x⌋ is the largest integer no more than x)

So here’s the question, if Steven wants to control the number of pages no more than P, what’s the maximum font size he can set? Note that paragraphs must start in a new line and there is no empty line between paragraphs.

...
more »

hihocoder 1148 — 2月29日

1 描述

给定两个日期,计算这两个日期之间有多少个2月29日(包括起始日期)。

只有闰年有2月29日,满足以下一个条件的年份为闰年:

  1. 年份能被4整除但不能被100整除

  2. 年份能被400整除

...
more »

Gradient descent & logistic regression

1 简介

这一章的 机器学习实战(第5章) ,唯一想说的就是里面关于梯度上升算法的细节问题。

...
more »

hihocoder 1148 — trie

1 Trie树

trie,又称前缀树或字典树。它利用字符串的公共前缀来节约存储空间。 性质:

  1. 根节点不包含字符,除根节点外的每个节点只包含一个字符。
  2. 从根节点到某一个节点,路径上经过的字符连接起来,为该节点对应的字符串。
  3. 每个节点的所有子节点包含的字符串不相同。

应用:

  1. 词频统计:比直接用hash节省空间
  2. 搜索提示:输入前缀的时候提示可以构成的词
  3. 作为辅助结构:如后缀树,AC自动机等的辅助结构
...
more »