#ABC106C. To Infinity
To Infinity
题目描述
Mr. Infinity has a string consisting of digits from 1 to 9. Each time the date changes, this string changes as follows:
- Each occurrence of
2in is replaced with22. Similarly, each3becomes333,4becomes4444,5becomes55555,6becomes666666,7becomes7777777,8becomes88888888and9becomes999999999.1remains as1.
For example, if is 1324, it becomes 1333224444 the next day, and it becomes 133333333322224444444444444444 the day after next. You are interested in what the string looks like after days. What is the -th character from the left in the string after days?
无穷先生有一个由 "1 "到 "9 "的数字组成的字符串 。每次日期改变,这个字符串都会发生如下变化:
- 在 中,每次出现的
2都被替换为22。同样,每个3变为333,4变为4444,5变为55555,6变为666666,7变为7777777,8变为88888888,9变为999999999。1 "仍为 "1"。例如,如果 是
1324,第二天就会变成1333224444,后天又会变成13333333224444444444。您想知道 天后字符串是什么样的。在 天之后,字符串中左起第 个字符是什么?
输入格式
输入内容按以下格式标准输入:
输出格式
在 天之后,打印无限先生字符串中从左边开始的 个字符。
样例 #1
样例输入 #1
1214
4
样例输出 #1
2
样例 #2
样例输入 #2
3
157
样例输出 #2
3
样例 #3
样例输入 #3
299792458
9460730472580800
样例输出 #3
2
说明
数据规模与约定
- 是长度在 和 (含)之间的字符串。
- 是介于 和 (含)之间的整数。
- 天后的字符串长度至少为 。
样例 解释
字符串 变化如下:
- 现在
1214 - 一天后
12214444 - 两天后
1222214444444444444444 - 三天后
12222222214444444444444444444444444444444444444444444444444444444444444444
在 天之后的字符串中,前五个字符是12222。作为 ,我们应该打印第四个字符 "2"。
样例 解释
初始字符串为 3。 天后的字符串只有3。