Codeforces Round #272 (Div. 1)D(字符串DP)_html/css_WEB-ITnose

php中文网
发布: 2016-06-24 11:56:19
原创
1137人浏览过

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.

快转字幕
快转字幕

新一代 AI 字幕工作站,为创作者提供字幕制作、学习资源、会议记录、字幕制作等场景,一键为您的视频生成精准的字幕。

快转字幕 357
查看详情 快转字幕

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

16
登录后复制

input

11010
登录后复制

output

35
登录后复制

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)


            注意一下细节即可


HTML速学教程(入门课程)
HTML速学教程(入门课程)

HTML怎么学习?HTML怎么入门?HTML在哪学?HTML怎么学才快?不用担心,这里为大家提供了HTML速学教程(入门课程),有需要的小伙伴保存下载就能学习啦!

下载
来源:php中文网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
开源免费商场系统广告
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号