No.1869 Doubling?
レベル : / 実行時間制限 : 1ケース 2.000秒 / メモリ制限
: 512 MB / 標準ジャッジ問題
タグ : / 解いたユーザー数 136
作問者 :
Falcon_
/ テスター :
ぷら
shiomusubi496
ytqm3
MtSaka
タグ : / 解いたユーザー数 136
作問者 :
ぷら
shiomusubi496
問題文最終更新日: 2022-03-11 14:46:02
English (AI translation)
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence.
Back to the original
yukicoder contest 335
(順位表)
の他の問題:
Problem Statement
You are given positive integers $N,M$. Consider a sequence of positive integers $A = (A_1, A_2, \ldots, A_N)$ that satisfies all of the following conditions.
- $A_1 = 1$
- For all $i\ (2 \le i \le N)$, $A_i \le M$
- For all $i\ (2 \le i \le N)$, $A_i = 2A_{i-1}$ or $A_i = 2A_{i-1} - 1$
It can be shown that under the constraints of this problem, a sequence $A$ satisfying the conditions always exists. Find a sequence $A$ satisfying the conditions whose sum of elements is maximum, and output that sum.
(Original idea: Cyanmond)
Input
$N$ $M$
- $1 \leq N, M \leq 10^9$
- All inputs are integers
Output
Output the answer on $1$ line.
Sample
Sample 1
Input
4 5
Output
11
Taking $A = (1, 2, 3, 5)$ is optimal.
Sample 2
Input
2021 1
Output
2021
Sample 3
Input
314 159
Output
625
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。