CF1383E.Strange Operation
省选/NOI-
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Koa the Koala has a binary string s of length n. Koa can perform no more than n−1 (possibly zero) operations of the following form:
In one operation Koa selects positions i and i+1 for some i with 1≤i<∣s∣ and sets si to max(si,si+1). Then Koa deletes position i+1 from s (after the removal, the remaining parts are concatenated).
Note that after every operation the length of s decreases by 1.
How many different binary strings can Koa obtain by doing no more than n−1 (possibly zero) operations modulo 109+7 (1000000007)?
考拉熊 Koa 有一个长度为 n 的二进制字符串 s。Koa 最多可以执行 n−1 次(可能为零次)如下形式的操作:
在一次操作中,Koa 选择某个满足 1≤i<∣s∣ 的位置 i 和 i+1,并将 si 设置为 max(si,si+1);然后 Koa 将位置 i+1 从 s 中删除(删除后,剩余部分被连接起来)。
注意:每次操作后,s 的长度都会减少 1。
Koa 最多执行 n−1 次(可能为零次)操作,能获得多少种不同的二进制字符串?答案对 109+7(即 1000000007)取模。
输入格式
The only line of input contains binary string s (1≤∣s∣≤106). For all i (1≤i≤∣s∣) si=0 or si=1.
输入仅包含一个二进制字符串 s(1≤∣s∣≤106)。对于所有 i(1≤i≤∣s∣),均有 si=0 或 si=1。
输出格式
On a single line print the answer to the problem modulo 109+7 (1000000007).
在一行中输出该问题的答案对 109+7(即 1000000007)取模的结果。
输入输出样例
输入#1
000
输出#1
3
输入#2
0101
输出#2
6
输入#3
0001111
输出#3
16
输入#4
00101100011100
输出#4
477
说明/提示
In the first sample Koa can obtain binary strings: 0, 00 and 000.
In the second sample Koa can obtain binary strings: 1, 01, 11, 011, 101 and 0101. For example:
- to obtain 01 from 0101 Koa can operate as follows: 0101→0(10)1→011→0(11)→01.
- to obtain 11 from 0101 Koa can operate as follows: 0101→(01)01→101→1(01)→11.
Parentheses denote the two positions Koa selected in each operation.
在第一个样例中,Koa 可以得到的二进制字符串有:0、00 和 000。
在第二个样例中,Koa 可以得到的二进制字符串有:1、01、11、011、101 和 0101。例如:
- 从 0101 得到 01 的操作过程如下:0101→0(10)1→011→0(11)→01。
- 从 0101 得到 11 的操作过程如下:0101→(01)01→101→1(01)→11。
括号表示 Koa 每次操作所选中的两个位置。
输入解题思路,AI测评打分。不知道怎么写?