Codeforces Round #272 (Div. 1)D(字符串DP)
2 seconds
512 megabytes
standard input
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:
- Print n in binary form without leading zeros, each print will append to the right of previous prints.
- 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.
The single line of the input contains a binary integer representing x (1 ≤ x < 25000)
without leading zeros.
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).
101
1
6
11010
3
5
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.
Codeforces Round #272 (Div. 1)D(字符串DP)的更多相关文章
- Codeforces Round #272 (Div. 2) 题解
Codeforces Round #272 (Div. 2) A. Dreamoon and Stairs time limit per test 1 second memory limit per ...
- 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 ...
- 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 ...
- 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 ...
- Codeforces Round #272 (Div. 2) E. Dreamoon and Strings 动态规划
E. Dreamoon and Strings 题目连接: http://www.codeforces.com/contest/476/problem/E Description Dreamoon h ...
- Codeforces Round #367 (Div. 2)---水题 | dp | 01字典树
A.Beru-taxi 水题:有一个人站在(sx,sy)的位置,有n辆出租车,正向这个人匀速赶来,每个出租车的位置是(xi, yi) 速度是 Vi;求人最少需要等的时间: 单间循环即可: #inclu ...
- Codeforces Round #131 (Div. 1) B. Numbers dp
题目链接: http://codeforces.com/problemset/problem/213/B B. Numbers time limit per test 2 secondsmemory ...
- Codeforces Round #131 (Div. 2) B. Hometask dp
题目链接: http://codeforces.com/problemset/problem/214/B Hometask time limit per test:2 secondsmemory li ...
- Codeforces Round #276 (Div. 1) D. Kindergarten dp
D. Kindergarten Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/problemset/proble ...
随机推荐
- AutoFac使用方法总结:Part I
注册部分 使用RegisterType进行注册 [Fact] public void can_resolve_myclass() { var builder = new ContainerBuilde ...
- Quartz2D裁剪圆形头像
// 0. 载入原有图片 UIImage *image = [UIImage imageNamed:icon]; // 1.创建图片上下文 CGFloat margin = border; CGSiz ...
- 阅读<反欺骗的艺术>思考
早期接受csdn发送本书<反欺骗的艺术 ---- 传说中的黑客世界里,分享经验>. 经过这本书发生床头, 每天晚上看上.直到今天, 刚读的书. 颇有感觉. 之所以当初选择读这本书, 完全被 ...
- JDBC batch批量Statement executeBatch 详细解释
JDBC提供了数据库batch处理的能力,在数据大批量操作(新增.删除等)的情况下能够大幅度提升系统的性能.我曾经接触的一个项目,在没有採用batch处理时,删除5万条数据大概要半个小时左右,后来对系 ...
- 最新jhost免费jsp云空间会员邀请码
jhost支持jsp.php的免费云空间,邀请码用于激活空间服务: 邀请码:20141003104317_149661 有效期:2014-10-03 http://w ...
- [three.js] 地图不能解决重复的问题 Solving with Texture RepeatWrapping Fail Issue
有些事情,如果你正在寻找侯,怎么也找不到. 有的东西,不经意间,到处: 我认为这是生活中常有的事. 然而,在互联网的浩瀚大海,这同样适用. 正常的一小会儿的积累, 投入少, 积累, 洋大海, 载起一帆 ...
- Following unknown configure options were used:--enable-fpm
跑cd php-5.2.13安装时间 ./configure --prefix=/usr/local/php/ --with-config-file-path=/usr/local/php/etc ...
- HDU 2460 Network(双连通+树链剖分+线段树)
HDU 2460 Network 题目链接 题意:给定一个无向图,问每次增加一条边,问个图中还剩多少桥 思路:先双连通缩点,然后形成一棵树,每次增加一条边,相当于询问这两点路径上有多少条边,这个用树链 ...
- 《web全栈工程师的自我修养》阅读笔记
在买之前以为这本书是教你怎么去做一个web全栈工程师,以及介绍需要掌握的哪些技术的书,然而看的过程中才发现,是一本方法论的书.读起来的感觉有点像红衣教主的<我的互联网方法论>,以一些自己的 ...
- 数据库开发——参照完整性——在外键中使用Delete on cascade选项
原文:数据库开发--参照完整性--在外键中使用Delete on cascade选项 原文: http://www.mssqltips.com/sqlservertip/2743/using-dele ...