QOJ.ac

QOJ

حد الوقت: 2.0 s حد الذاكرة: 512 MB مجموع النقاط: 100 قابلة للهجوم ✓

#10515. 砝碼

الإحصائيات

Link 有 $m$ 個砝碼,每個砝碼的重量都是一個正整數。

已知 Link 可以用這些砝碼稱出 $1$ 到 $n$ 中的所有整數重量(砝碼僅能放在天平的同一邊),Link 手上最重的砝碼至少有多重?

注意:Link 手上的砝碼能否表示出 $n + 1$ 或更大的重量是未知的。

輸入格式

每個測試文件包含多組測試數據。第一行包含測試數據的組數 $T$ ($1 \le T \le 2 \times 10^5$)。每組測試數據的格式如下:

第一行包含兩個整數 $n$ 和 $m$ ($1 \le n, m \le 10^9$),表示砝碼能表示的已知最大重量和砝碼的數量。

輸出格式

對於每組數據,輸出一行一個整數,表示 Link 手上最重的砝碼的重量的最小值。如果不可能用 $m$ 個砝碼表示出 $1$ 到 $n$ 中的所有重量,請輸出 “-1”。

範例

輸入格式 1

2
40 6
16 4

輸出格式 1

13
-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.