BNY MellonOA #1
Calculate String Transformations Length
HardJudge-ready
Apply exactly t rounds of simultaneous transformation to a lowercase English string: each z is replaced with ab, and every other letter is replaced with the next letter of the alphabet. Characters produced in a round are not transformed again until the next round. Output the final string length modulo 1000000007.
Input
Exactly two lines: the first line is word, containing only a..z; the second line is a non-negative integer t. Based on the original Java int interface and the round semantics, this site explicitly interprets 0≤t≤2147483647; this range is derived from the type rather than given as a number in the original constraints section. The original has no upper bound on the length of word; this site covers every valid transmittable string within the 32MiB standard input budget of a single test case, without further reducing the length. The first line may be empty, as this site's mathematical extension to the empty string.
Output
Output one integer: the final length modulo 1000000007. When t=0, return the original length modulo it; an empty string always returns 0.
Example 1
Input:
azbk
1
Output:
5
Example 2
Input:
abczy
2
Output:
7
Example 3
Input:
z
0
Output:
1
Example notes
In the original statement, azbk becomes babcl after one round, length 5. In the original example abczy,t=2, it first becomes bcdabz and then cdebcab, length 7; the original output was TO-DO, and 7 was filled in by this site by deriving it from the explicit rules; the original explanation cdedbc is wrong. The third public example z,t=0→1 is a boundary case added by this site.
Editorial
Loading solution…