CF1204B.Mislove Has Lost an Array

入门

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

Mislove had an array a1a_1, a2a_2, ⋯\cdots, ana_n of nn positive integers, but he has lost it. He only remembers the following facts about it:

  • The number of different numbers in the array is not less than ll and is not greater than rr;
  • For each array's element aia_i either ai=1a_i = 1 or aia_i is even and there is a number ai2\dfrac{a_i}{2} in the array.

For example, if n=5n=5, l=2l=2, r=3r=3 then an array could be [1,2,2,4,4][1,2,2,4,4] or [1,1,1,1,2][1,1,1,1,2]; but it couldn't be [1,2,2,4,8][1,2,2,4,8] because this array contains 44 different numbers; it couldn't be [1,2,2,3,3][1,2,2,3,3] because 33 is odd and isn't equal to 11; and it couldn't be [1,1,2,2,16][1,1,2,2,16] because there is a number 1616 in the array but there isn't a number 162=8\frac{16}{2} = 8.

According to these facts, he is asking you to count the minimal and the maximal possible sums of all elements in an array.

Mislove 原本有一个由 nn 个正整数组成的数组 a1a_1, a2a_2, ⋯\cdots, ana_n,但他弄丢了。他只记得关于该数组的如下事实:

  • 数组中不同数字的个数不少于 ll,且不大于 rr;
  • 对于数组中的每个元素 aia_i,要么 ai=1a_i = 1,要么 aia_i 是偶数,且 ai2\dfrac{a_i}{2} 也在数组中。

例如,若 n=5n=5,l=2l=2,r=3r=3,则数组可以是 [1,2,2,4,4][1,2,2,4,4] 或 [1,1,1,1,2][1,1,1,1,2];但不能是 [1,2,2,4,8][1,2,2,4,8],因为该数组包含 44 个不同的数;不能是 [1,2,2,3,3][1,2,2,3,3],因为 33 是奇数且不等于 11;也不能是 [1,1,2,2,16][1,1,2,2,16],因为数组中存在 1616,但不存在 162=8\frac{16}{2} = 8。

根据这些事实,他请你计算该数组所有元素之和的最小可能值与最大可能值。

输入格式

The only input line contains three integers nn, ll and rr (1≤n≤1 0001 \leq n \leq 1\,000, 1≤l≤r≤min⁡(n,20)1 \leq l \leq r \leq \min(n, 20)) — an array's size, the minimal number and the maximal number of distinct elements in an array.

唯一的一行输入包含三个整数 nn、ll 和 rr(1≤n≤1 0001 \leq n \leq 1\,000,1≤l≤r≤min⁡(n,20)1 \leq l \leq r \leq \min(n, 20))——分别表示数组的大小、数组中不同元素的最小个数和最大个数。

输出格式

Output two numbers — the minimal and the maximal possible sums of all elements in an array.

输出两个数——数组中所有元素和的最小值与最大值。

输入输出样例

  • 输入#1

    4 2 2

    输出#1

    5 7
  • 输入#2

    5 1 5

    输出#2

    5 31

说明/提示

In the first example, an array could be the one of the following: [1,1,1,2][1,1,1,2], [1,1,2,2][1,1,2,2] or [1,2,2,2][1,2,2,2]. In the first case the minimal sum is reached and in the last case the maximal sum is reached.

In the second example, the minimal sum is reached at the array [1,1,1,1,1][1,1,1,1,1], and the maximal one is reached at the array [1,2,4,8,16][1,2,4,8,16].

在第一个例子中,数组可以是以下之一:[1,1,1,2][1,1,1,2]、[1,1,2,2][1,1,2,2] 或 [1,2,2,2][1,2,2,2]。第一种情况下达到最小和,最后一种情况下达到最大和。

在第二个例子中,最小和在数组 [1,1,1,1,1][1,1,1,1,1] 处取得,最大和在数组 [1,2,4,8,16][1,2,4,8,16] 处取得。

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

首页