D. Dreamoon and Binary
time limit per test

2 seconds

memory limit per test

512 megabytes

input

standard input

output

standard output

Dreamoon saw a large integer x written on the ground and wants to print its binary form out. Dreamoon has accomplished the part of turning x into
its binary format. Now he is going to print it in the following manner.

He has an integer n = 0 and can only perform the following two operations in any order for unlimited times each:

  1. Print n in binary form without leading zeros, each print will append to the right of previous prints.
  2. Increase n by 1.

Let's define an ideal sequence as a sequence of operations that can successfully print binary representation of x without
leading zeros and ends with a print operation (i.e. operation 1). Dreamoon wants to know how many different ideal sequences are there and the length (in operations) of the shortest ideal sequence.

The answers might be large so please print them modulo 1000000007 (109 + 7).

Let's define the string representation of an ideal sequence as a string of '1' and '2' where
the i-th character in the string matches thei-th
operation performed. Two ideal sequences are called different if their string representations are different.

Input

The single line of the input contains a binary integer representing x (1 ≤ x < 25000)
without leading zeros.

Output

The first line of the output should contain an integer representing the number of different ideal sequences modulo 1000000007 (109 + 7).

The second line of the output contains an integer representing the minimal length of an ideal sequence modulo 1000000007 (109 + 7).

Sample test(s)
input
101
output
1
6
input
11010
output
3
5
Note

For the first sample, the shortest and the only ideal sequence is «222221» of length 6.

For the second sample, there are three ideal sequences «21211», «212222222221»,
«222222222222222222222222221». Among them the shortest one has length 5.

题意:RT

思路:就是求将原串分成多个数字,使得全部数字从左往右不递减即,求方案数

            dp[i][j]表示以i到j结尾的二进制数的总方案数

            dp[i][j] + = dp[k][i-1]  (当中k到i-1的二进制数要小于或等于i到j的二进制数)

            再用一个mi[i][j]表示以i到j结尾的二进制数前面最少的二进制数的数量

            mi[i][j] = min(mi[k][i-1]+1)

            注意一下细节就可以

Codeforces Round #272 (Div. 1)D(字符串DP)的更多相关文章

  1. Codeforces Round #272 (Div. 2) 题解

    Codeforces Round #272 (Div. 2) A. Dreamoon and Stairs time limit per test 1 second memory limit per ...

  2. Codeforces Round #272 (Div. 1)C(字符串DP)

    C. Dreamoon and Strings time limit per test 1 second memory limit per test 256 megabytes input stand ...

  3. Codeforces Round #272 (Div. 2) B. Dreamoon and WiFi dp

    B. Dreamoon and WiFi 题目连接: http://www.codeforces.com/contest/476/problem/B Description Dreamoon is s ...

  4. Codeforces Round #272 (Div. 2) E. Dreamoon and Strings dp

    题目链接: http://www.codeforces.com/contest/476/problem/E E. Dreamoon and Strings time limit per test 1 ...

  5. Codeforces Round #272 (Div. 2) E. Dreamoon and Strings 动态规划

    E. Dreamoon and Strings 题目连接: http://www.codeforces.com/contest/476/problem/E Description Dreamoon h ...

  6. Codeforces Round #367 (Div. 2)---水题 | dp | 01字典树

    A.Beru-taxi 水题:有一个人站在(sx,sy)的位置,有n辆出租车,正向这个人匀速赶来,每个出租车的位置是(xi, yi) 速度是 Vi;求人最少需要等的时间: 单间循环即可: #inclu ...

  7. Codeforces Round #131 (Div. 1) B. Numbers dp

    题目链接: http://codeforces.com/problemset/problem/213/B B. Numbers time limit per test 2 secondsmemory ...

  8. Codeforces Round #131 (Div. 2) B. Hometask dp

    题目链接: http://codeforces.com/problemset/problem/214/B Hometask time limit per test:2 secondsmemory li ...

  9. Codeforces Round #276 (Div. 1) D. Kindergarten dp

    D. Kindergarten Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/problemset/proble ...

随机推荐

  1. DM8168 CameraLink 视频噪点问题解决

    几天前写过FPGA採集LVDS视频(噪点去除),当时的情况是CameraLink视频出现了非常多噪点,不堪入目,硬件方面没有找到毛病,仅仅能是用硬件描写叙述语言对採集前端的FPGA又一次进行了处理,效 ...

  2. IE7,8,9兼容性处理

    在IE7根据假设高度文本框中设置,则光标将不会被中心的方法如以下: 添加属性,如:style="line-height:32px\9";能够 假设一个页面有多个TAB交换的物品.而 ...

  3. onsubmit事件

    var oForm = document.getElementById("form1"); oForm.onsubmit = function(){   alert("你 ...

  4. 编译命令行终端 swift

    So, this is where swift lives, after you've installed XCode 6 Beta: /Applications/Xcode6-Beta.app/Co ...

  5. 几款开源ESB总线的比较(转)

    现有的开源ESB总线中,自从2003年第一个开源总线Mule出现后,现在已经是百花争鸣的景象了.现在我就对现有的各种开源ESB总线依据性能.可扩展性.资料文档完整程度以及整合难易程度等方面展开. CX ...

  6. Windows 8实例教程系列 - 开篇

    原文:Windows 8实例教程系列 - 开篇 2012年10月26日,微软发布Windows 8操作系统以及自主品牌平板电脑Surface,Windows作为世界上最流行的操作系统,发布一周内,下载 ...

  7. PHP之运用CI用钩子实现URL权限控制————————【Badboy】

    <span style="background-color: rgb(247, 252, 255); font-family: Verdana, Arial, Helvetica, s ...

  8. SDL2来源分析7:演出(SDL_RenderPresent())

    ===================================================== SDL源代码分析系列文章上市: SDL2源码分析1:初始化(SDL_Init()) SDL2 ...

  9. asp.net web api KnownTypeAttribute

    项目里用到了继承,在序列化的时候遇到了问题. 源代码 public class Segment { public SegmentType Type { get; set; } public strin ...

  10. 解决因特网和xshell考虑到问题

    首先需要解释.我们学校的网络是免费的.无论是实验室或宿舍.因此,互联网是基于Mac地址分配IP的,所以我VirtualBox安装了centos之后,话.就须要将VirtualBox的mac地址改成和我 ...