CF1840B.Binary Cafe

普及-

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Once upon a time, Toma found himself in a binary cafe. It is a very popular and unusual place.

The cafe offers visitors kk different delicious desserts. The desserts are numbered from 00 to k−1k-1. The cost of the ii-th dessert is 2i2^i coins, because it is a binary cafe! Toma is willing to spend no more than nn coins on tasting desserts. At the same time, he is not interested in buying any dessert more than once, because one is enough to evaluate the taste.

In how many different ways can he buy several desserts (possibly zero) for tasting?

从前,托马来到了一家二进制咖啡馆。这是一家非常受欢迎且别具一格的场所。

咖啡馆为顾客提供 kk 种不同美味的甜点。这些甜点编号从 00 到 k−1k-1。第 ii 种甜点的价格为 2i2^i 枚硬币,毕竟这是一家二进制咖啡馆!托马愿意花费至多 nn 枚硬币来品尝甜点。同时,他对同一种甜点不感兴趣购买超过一次,因为尝一次就足以品鉴其风味了。

那么,他有多少种不同的方式(可能为零种)来购买若干种甜点进行品尝?

输入格式

The first line of the input contains a single integer tt (1≤t≤10001 \le t \le 1000) — the number of test cases.

Then follows tt lines, each of which describes one test case.

Each test case is given on a single line and consists of two integers nn and kk (1≤n,k≤1091 \le n, k \le 10^9) — the number of coins Toma is willing to spend and the number of desserts in the binary cafe.

输入的第一行包含一个整数 tt(1≤t≤10001 \le t \le 1000)—— 表示测试用例的数量。

接下来是 tt 行,每行描述一个测试用例。

每个测试用例占一行,包含两个整数 nn 和 kk(1≤n,k≤1091 \le n, k \le 10^9)—— 分别表示 Toma 愿意花费的硬币数量以及二进制咖啡馆中甜点的数量。

输出格式

Output tt integers, the ii-th of which should be equal to the answer for the ii-th test case — the number of ways to buy desserts for tasting.

输出 tt 个整数,其中第 ii 个整数应等于第 ii 个测试用例的答案——即购买甜点用于品尝的方案数。

输入输出样例

  • 输入#1

    5
    1 2
    2 1
    2 2
    10 2
    179 100

    输出#1

    2
    2
    3
    4
    180

说明/提示

Variants for 1st sample: {}, {1}

Variants for 2nd sample: {}, {1}

Variants for 3rd sample: {}, {1}, {2}

Variants for 4th sample: {}, {1}, {2}, {1, 2}

第1个样例的可能集合:{}, {1}

第2个样例的可能集合:{}, {1}

第3个样例的可能集合:{}, {1}, {2}

第4个样例的可能集合:{}, {1}, {2}, {1, 2}

输入解题思路,AI测评打分。不知道怎么写?

首页