当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

1302:Blue Gene, Jr.

题目描述
Inspired by IBM's Blue Gene project, the CEO of Universal Biological Machinery (UBM), has called on you, UBM's top software engineer, to develop a program that will calculate the mutation of the Areopagus-virus, a virus discovered on Mars by your company's privately-subsidized (top-secret) space program.
输入解释
Input to this problem will consist of a (non-empty) series of up to 100 data sets. Each data set will be formatted according to the following description, and there will be no blank lines separating data sets.
A single data set has 3 components:

  1. Start line - A single line, "START N", where 1 <= N <= 20.
  2. Viral code - A sequence of N alphanumeric characters. Alphanumeric characters will consist of an uppercase letter (A-Z) or a digit (0-9).
  3. End line - A single line, "END"

Following the final data set will be a single line, "ENDOFINPUT".
输出解释
For each data set, there will be exactly one output set, and there will be no blank lines separating output sets.

A single output set consists of a single line of the viral code after it has stabilized (through mutating).

The viral code will mutate according to the following rules:

  1. Initially the first viral segment to mutate begins with the first alphanumeric character of the viral code and ends with the rightmost alphanumeric character of the code.
  2. If the first alphanumeric character of a viral segment is a letter (A-Z), that alphanumeric character is considered "unstable", and will mutate into n, where n is the number of mutations that occur to the viral segment immediately to the unstable alphanumeric character's right (see #5), unless n is greater than 9, in which case the unstable alphanumeric character will mutate into n % 10. Also, if there is no viral segment immediately to the right of the unstable alphanumeric character, the unstable alphanumeric character will mutate into 0.
  3. If the first alphanumeric character of a viral segment, n, is a positive number (1-9), that alphanumeric character is also considered "unstable", and will mutate into n-1. It also causes the viral segment beginning with the alphanumeric character n alphanumeric characters to its right and ending with the rightmost alphanumeric character of the viral code to mutate. If there is no alphanumeric character n alphanumeric characters to its right, then the viral segment immediately to its right (see #5), if one exists, will mutate.
  4. If the first alphanumeric character of a viral segment is 0, that alphanumeric character is considered "stable", and will not mutate (the alphanumeric character will remain a 0 and a mutation will not be considered to have occurred).
  5. A viral segment immediately to the right of an alphanumeric character begins with the alphanumeric character one position to its right and ending with the rightmost alphanumeric character of the viral code.
输入样例
START 1
A
END
START 4
A1B2
END
START 15
A3B2CCC4AD1232R
END
START 15
0ABCDEFGHIJKLMN
END
START 11
ABCDEFGHIJK
END
START 10
9AAAAAAAAA
END
ENDOFINPUT
输出样例
0
3011
82B26543AD11310
0ABCDEFGHIJKLMN
09876543210
8AAAAAAAA0

该题目是Virtual Judge题目,来自 北京大学POJ

题目来源 South Central USA 2002

源链接: POJ-1302

最后修改于 2020-10-29T06:00:32+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
1000 10000