QOJ.ac

QOJ

時間限制: 1 s 記憶體限制: 256 MB 總分: 100

#7825. 编程基础

统计

在学习“整数的二进制表示”这一主题时,计算机科学老师想出了下面这道题。给定两个整数 $N$ 和 $M$。请找出 $M$ 的二进制表示在 $N$ 的二进制表示中第一次出现的位置索引,假设两个二进制表示均不包含前导零。你能解决这个问题吗?

输入格式

在唯一的一行中包含两个由空格分隔的非负整数 $N$ 和 $M$,满足 $0 \leqslant M \leqslant N \leqslant 10^{19}$。

输出格式

在唯一的一行中输出一个整数,表示 $M$ 的二进制表示在 $N$ 的二进制表示中第一次出现的位置索引。最左侧位置的索引视为 $0$。如果不存在,则输出 $-1$。

样例

样例输入 1

6 2

样例输出 1

1

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.