A16036 | Binary Cafe
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Once upon a time, Toma found himself in a binary cafe. It is a very popular and unusual place.
The cafe offers visitors $k$ different delicious desserts. The desserts are numbered from $0$ to $k-1$ . The cost of the $i$ -th dessert is $2^i$ coins, because it is a binary cafe! Toma is willing to spend no more than $n$ 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?
The cafe offers visitors $k$ different delicious desserts. The desserts are numbered from $0$ to $k-1$ . The cost of the $i$ -th dessert is $2^i$ coins, because it is a binary cafe! Toma is willing to spend no more than $n$ 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?
输入格式
The first line of the input contains a single integer $t$ ( $1 \le t \le 1000$ ) — the number of test cases.
Then follows $t$ lines, each of which describes one test case.
Each test case is given on a single line and consists of two integers $n$ and $k$ ( $1 \le n, k \le 10^9$ ) — the number of coins Toma is willing to spend and the number of desserts in the binary cafe.
Then follows $t$ lines, each of which describes one test case.
Each test case is given on a single line and consists of two integers $n$ and $k$ ( $1 \le n, k \le 10^9$ ) — the number of coins Toma is willing to spend and the number of desserts in the binary cafe.
输出格式
Output $t$ integers, the $i$ -th of which should be equal to the answer for the $i$ -th test case — the number of ways to buy desserts for tasting.
输入输出样例
输入 #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}
Variants for 2nd sample: {}, {1}
Variants for 3rd sample: {}, {1}, {2}
Variants for 4th sample: {}, {1}, {2}, {1, 2}
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted