CF374B.Inna and Nine
普及/提高-
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Inna loves digit 9 very much. That's why she asked Dima to write a small number consisting of nines. But Dima must have misunderstood her and he wrote a very large number a, consisting of digits from 1 to 9.
Inna wants to slightly alter the number Dima wrote so that in the end the number contained as many digits nine as possible. In one move, Inna can choose two adjacent digits in a number which sum equals 9 and replace them by a single digit 9.
For instance, Inna can alter number 14545181 like this: 14545181 → 1945181 → 194519 → 19919. Also, she can use this method to transform number 14545181 into number 19991. Inna will not transform it into 149591 as she can get numbers 19919 and 19991 which contain more digits nine.
Dima is a programmer so he wants to find out how many distinct numbers containing as many digits nine as possible Inna can get from the written number. Help him with this challenging task.
茵娜非常喜爱数字 9。因此,她请迪马写一个仅由数字 9 组成的小数。但迪马可能误解了她的意思,写出了一个非常大的数 a,该数仅由数字 1 到 9 构成。
茵娜希望对迪马所写的数稍作修改,使得最终得到的数中包含尽可能多的数字 9。在一次操作中,茵娜可以选择该数中两个相邻且和为 9 的数字,并将它们替换为单个数字 9。
例如,茵娜可以这样修改数字 14545181:
14545181 → 1945181 → 194519 → 19919。
此外,她也可以用此方法将 14545181 变为 19991。茵娜不会将其变为 149591,因为 19919 和 19991 包含更多的数字 9。
迪马是一名程序员,他想弄清楚:从给定的数出发,茵娜最多能获得多少个互不相同、且包含最多可能个数的数字 9 的数。请帮助他完成这项具有挑战性的任务。
输入格式
The first line of the input contains integer a (1 ≤ a ≤ 10100000). Number a doesn't have any zeroes.
输入的第一行包含一个整数 a(1 ≤ a ≤ 10100000)。数字 a 不含任何零。
输出格式
In a single line print a single integer — the answer to the problem. It is guaranteed that the answer to the problem doesn't exceed 263 - 1.
Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier.
在一行中输出一个整数——即该问题的答案。保证问题的答案不超过 263−1。
请注意,在 C++ 中读写 64 位整数时,请勿使用 %lld 说明符。推荐使用 cin、cout 流,或 %I64d 说明符。
输入输出样例
输入#1
369727
输出#1
2
输入#2
123456789987654321
输出#2
1
输入#3
1
输出#3
1
说明/提示
Notes to the samples
In the first sample Inna can get the following numbers: 369727 → 99727 → 9997, 369727 → 99727 → 9979.
In the second sample, Inna can act like this: 123456789987654321 → 12396789987654321 → 1239678998769321.
样例说明
在第一个样例中,Inna 可以得到以下数字:369727 → 99727 → 9997,以及 369727 → 99727 → 9979。
在第二个样例中,Inna 可以按如下方式操作:123456789987654321 → 12396789987654321 → 1239678998769321。
输入解题思路,AI测评打分。不知道怎么写?