Sum Equals Xor

给定一个正整数L的二进制表示,求所有非负整数对(a, b),使得a + b ≤ L且a + b = a ^ b,输出满足条件的数对数量模10^9 + 7。文章包含样例输入输出及解题思路。" 123683379,13011111,Java基础知识精讲:标识符与数据类型,"['JavaSE', '程序设计', '数据类型', '类型转换', '基础概念']
摘要由CSDN通过智能技术生成

Sum Equals Xor

题目描述

You are given a positive integer L in base two. How many pairs of non-negative integers (a,b) satisfy the following conditions?
·a+b≤L
·a+b=a XOR b
Since there can be extremely many such pairs, print the count modulo 109+7.
→What is XOR?
The XOR of integers A and B, A XOR B, is defined as follows:
·When A XOR B is written in base two, the digit in the 2k’s place (k≥0) is 1 if either A or B, but not both, has 1 in the 2k’s place, and 0 otherwise.
For example, 3 XOR 5=6. (In base two: 011 XOR 101=110.)

Constraints
·L is given in base two, without leading zeros.
·1≤L<2100001

输入
Input is given from Standard Input in the following format:

L

输出
Print the number of pairs (a,b) that satisfy the conditions, modulo 109+7.

样例输入
【样例1】
10
【样例2】
1111111111111111111

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值