#125. 密码代码

密码代码

题目描述

农民约翰收到一条的消息,记该消息为长度至少为2,只由大写字母组成的字符串S,他通过一系列操作对S进行加密。

他的操作为,删除S的前面或者后面的若干个字符(但不删光整个S),并将剩下的部分连接到原字符串S的前面或者后面。如对于S=‘ABC’,共有8总可能的操作结果:

AABC

ABABC

BCABC

CABC

ABCA

ABCAB

ABCBC

ABCC

给出加密后的目标字符串,请计算共有多少种加密的方案。

对于同字符的字符串,加密方案不止一种,比如把AA加密成AAA,共有4种加密方案。将你的答案mod 2014后输出。

输入格式

* Line 1: A single encrypted string of length at most 100.

输出格式

* Line 1: The number of ways FJ could have produced this string with one or more successive operations applied to some initial string of length at least 2, written out modulo 2014. If there are no such ways, output zero.

输入输出样例 #1

输入 #1

ABABA

输出 #1

8

说明/提示

Here are the different ways FJ could have produced ABABA:

  1. Start with ABA -> AB+ABA

  2. Start with ABA -> ABA+BA

  3. Start with AB -> AB+A -> AB+ABA

  4. Start with AB -> AB+A -> ABA+BA

  5. Start with BA -> A+BA -> AB+ABA

  6. Start with BA -> A+BA -> ABA+BA

  7. Start with ABAB -> ABAB+A

  8. Start with BABA -> A+BABA