CF992C.Nastya and a Wardrobe
普及/提高-
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Nastya received a gift on New Year — a magic wardrobe. It is magic because in the end of each month the number of dresses in it doubles (i.e. the number of dresses becomes twice as large as it is in the beginning of the month).
Unfortunately, right after the doubling the wardrobe eats one of the dresses (if any) with the 50% probability. It happens every month except the last one in the year.
Nastya owns x dresses now, so she became interested in the expected number of dresses she will have in one year. Nastya lives in Byteland, so the year lasts for k + 1 months.
Nastya is really busy, so she wants you to solve this problem. You are the programmer, after all. Also, you should find the answer modulo 109 + 7, because it is easy to see that it is always integer.
娜斯佳在新年收到了一件礼物——一个魔法衣柜。它之所以是“魔法”的,是因为每个月末,其中的裙子数量都会翻倍(即变为该月月初数量的两倍)。
不幸的是,每次翻倍之后,衣柜会以 50% 的概率“吃掉”其中一条裙子(如果有的话)。这一事件每月都会发生,但不包括一年中的最后一个月。
娜斯佳目前拥有 x 条裙子,因此她很想知道一年后她所拥有的裙子数量的期望值(期望值)。娜斯佳生活在比特兰(Byteland),因此当地的一年共持续 k+1 个月。
娜斯佳非常忙,所以她希望你来解决这个问题——毕竟,你可是程序员!此外,由于答案恒为整数,你需要将结果对 109+7 取模。
输入格式
The only line contains two integers x and k (0 ≤ x, k ≤ 1018), where x is the initial number of dresses and k + 1 is the number of months in a year in Byteland.
唯一一行包含两个整数 x 和 k(0 ≤ x, k ≤ 1018),其中 x 是初始的裙子数量,k + 1 是 Byteland 一年中的月份数。
输出格式
In the only line print a single integer — the expected number of dresses Nastya will own one year later modulo 109 + 7.
在唯一的一行中输出一个整数——娜斯佳一年后拥有的裙子数量的期望值对 109+7 取模的结果。
输入输出样例
输入#1
2 0
输出#1
4
输入#2
2 1
输出#2
7
输入#3
3 2
输出#3
21
说明/提示
In the first example a year consists on only one month, so the wardrobe does not eat dresses at all.
In the second example after the first month there are 3 dresses with 50% probability and 4 dresses with 50% probability. Thus, in the end of the year there are 6 dresses with 50% probability and 8 dresses with 50% probability. This way the answer for this test is (6 + 8) / 2 = 7.
在第一个例子中,一年只包含一个月,因此衣柜根本不会“吃掉”衣服。
在第二个例子中,第一个月结束后,有 50% 的概率剩下 3 件衣服,另有 50% 的概率剩下 4 件衣服。因此,到年底时,有 50% 的概率剩下 6 件衣服,另有 50% 的概率剩下 8 件衣服。于是,该测试用例的答案为 (6 + 8) / 2 = 7。
输入解题思路,AI测评打分。不知道怎么写?