# 111qqz的小窝

## bestcoder #88 || hdu 5908 Abelian Period(暴力)

• 首先我们发现，所有的阿贝尔周期一定是数字串长度（设为n)的因数。
• 然后我们还发现。。。如果某个因子是阿贝尔周期，那么该因子的整数倍中恰好也是n的因子的也一定是阿贝尔周期，类似筛法。
• 然后我们还发现。。。最小的阿贝尔周期一定比数字串中的元素个数大。。。

## codeforces #368 div 2 A. Brain’s Photos (暴力)

。。。这题也能成hack题。。。。有毒啊。。然后我room里所有人都写对了。。。是我看这道题看得太早了？

cf689C

## poj 3368 Frequent values （暴力+rmq，分类讨论）

poj 3368 题目链接

f[i] = f[i-1] + 1 (iff a[i]==a[i-1])

hdu3183题目链接

## 1653: [Usaco2006 Feb]Backward Digit Sums

Time Limit: 5 Sec  Memory Limit: 64 MB
Submit: 349  Solved: 258
[Submit][Status][Discuss]

## Description

FJ and his cows enjoy playing a mental game. They write down the numbers from 1 to N (1 <= N <= 10) in a certain order and then sum adjacent numbers to produce a new list with one fewer number. They repeat this until only a single number is left. For example, one instance of the game (when N=4) might go like this: 3 1 2 4 4 3 6 7 9 16 Behind FJ’s back, the cows have started playing a more difficult game, in which they try to determine the starting sequence from only the final total and the number N. Unfortunately, the game is a bit above FJ’s mental arithmetic capabilities. Write a program to help FJ play the game and keep up with the cows.

## Input

* Line 1: Two space-separated integers: N and the final sum.

## Output

* Line 1: An ordering of the integers 1..N that leads to the given sum. If there are multiple solutions, choose the one that is lexicographically least, i.e., that puts smaller numbers first.

4 16

## Sample Output

3 1 2 4
OUTPUT DETAILS:

There are other possible sequences, such as 3 2 1 4, but 3 1 2 4
is the lexicographically smallest.

## 1622: [Usaco2008 Open]Word Power 名字的能量

Time Limit: 5 Sec  Memory Limit: 64 MB
Submit: 462  Solved: 228
[Submit][Status][Discuss]

## Description

约翰想要计算他那N(1≤N≤1000)只奶牛的名字的能量．每只奶牛的名字由不超过1000个字待构成，没有一个名字是空字体串，  约翰有一张“能量字符串表”，上面有M(1≤M≤100)个代表能量的字符串．每个字符串由不超过30个字体构成，同样不存在空字符串．一个奶牛的名字蕴含多少个能量字符串，这个名字就有多少能量．所谓“蕴含”，是指某个能量字符串的所有字符都在名字串中按顺序出现（不一定一个紧接着一个）．
所有的大写字母和小写字母都是等价的．比如，在贝茜的名字“Bessie”里，蕴含有“Be”
“sI”“EE”以及“Es”等等字符串，但不蕴含“lS”或“eB”．请帮约翰计算他的奶牛的名字的能量．

## Input

第1行输入两个整数N和M，之后N行每行输入一个奶牛的名字，之后M行每行输入一个能量字符串．

## Output

一共N行，每行一个整数，依次表示一个名字的能量．

## Sample Input

5 3
Bessie
Jonathan
Montgomery
Alicia
Angola
se
nGo
Ont

INPUT DETAILS:

There are 5 cows, and their names are “Bessie”, “Jonathan”,
“Montgomery”, “Alicia”, and “Angola”. The 3 good strings are “se”,
“nGo”, and “Ont”.

## Sample Output

1
1
2
0
1

OUTPUT DETAILS:

“Bessie” contains “se”, “Jonathan” contains “Ont”, “Montgomery” contains
both “nGo” and “Ont”, Alicia contains none of the good strings, and
“Angola” contains “nGo”.

## 1599: [Usaco2008 Oct]笨重的石子

Time Limit: 10 Sec  Memory Limit: 162 MB
Submit: 886  Solved: 614
[Submit][Status][Discuss]

## Input

*第一行：三个由空格隔开的整数：s1,s2,s3

*第一行：所要求的解

3 2 3

## Sample Output

5

1 1 1 -> 3 1 2 1 -> 4 2 1 1 -> 4 2 2 1 -> 5 3 1 1 -> 5 3 2 1 -> 6

1 1 2 -> 4 1 2 2 -> 5 2 1 2 -> 5 2 2 2 -> 6 3 1 2 -> 6 3 2 2 -> 7

1 1 3 -> 5 1 2 3 -> 6 2 1 3 -> 6 2 2 3 -> 7 3 1 3 -> 7 3 2 3 -> 8

5和6出现的几率都是最大的，所以输出5.