QOJ.ac

QOJ

时间限制: 2.0 s 内存限制: 512 MB 总分: 100 可 Hack ✓

#16935. 双截棍商店

统计

Nathan 拥有一家出售独特设计纪念品双节棍的商店。双节棍是一种传统的武术兵器,由两条用链条连接的棍子组成。在 Nathan 的设计中,每条棍子上都镶嵌着排成一排的 $n$ 颗宝石。这些宝石要么是石英,要么是玛瑙,它们构成了一种美观的黑白图案。出于美学考虑,Nathan 只出售两条棍子上总共恰好有 $k$ 颗玛瑙的双节棍。例如,下图是 $n = 4$ 且 $k = 5$ 时的一种可能设计:

最近,Nathan 决定如果能出售所有可能设计的双节棍那就太好了。但这需要他在仓库中备有所有可能设计的双节棍,而可能的设计数量是巨大的!

因此,Nathan 决定做出妥协。他将在仓库中存放一定数量的单条棍子。当有顾客订购某种设计的双节棍时,Nathan 会从仓库中取出两条棍子,并用链条将它们连接起来。棍子是对称的,Nathan 可以将链条连接到棍子的任意一端。例如,如果 $n = 3$ 且 $k = 2$,并且 Nathan 的仓库中拥有以下棍子:

那么他就可以制作出任何可能设计的双节棍。例如,如果顾客要求如下设计的双节棍:

那么 Nathan 可以用棍子 1 和棍子 3 来制作它。

现在 Nathan 想知道:他最少需要在仓库中存放多少条棍子,才能制作出任何可能设计的双节棍?请帮助他求出这个数量。

输入格式

输入包含两个整数 $n$ 和 $k$($1 \le n \le 50$;$0 \le k \le 2 \cdot n$)。

输出格式

输出一个整数:Nathan 仓库中需要存放的最少棍子数量。

样例

输入样例 1

3 2

输出样例 1

7

输入样例 2

4 1

输出样例 2

3

输入样例 3

5 0

输出样例 3

2

输入样例 4

50 50

输出样例 4

626155273417404

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.