HSI(AtCoder-3671)

Problem Description

Takahashi is now competing in a programming contest, but he received TLE in a problem where the answer is YES or NO.

When he checked the detailed status of the submission, there were N test cases in the problem, and the code received TLE in M of those cases.

Then, he rewrote the code to correctly solve each of those M cases with 1⁄2 probability in 1900 milliseconds, and correctly solve each of the other N−M cases without fail in 100 milliseconds.

Now, he goes through the following process:

Submit the code.
Wait until the code finishes execution on all the cases.
If the code fails to correctly solve some of the M cases, submit it again.
Repeat until the code correctly solve all the cases in one submission.
Let the expected value of the total execution time of the code be X milliseconds. Print X (as an integer).

Constraints

  • All input values are integers.
  • 1≤N≤100
  • 1≤M≤min(N,5)

Input

Input is given from Standard Input in the following format:

N M

Output

Print X, the expected value of the total execution time of the code, as an integer. It can be proved that, under the constraints in this problem, X is an integer not exceeding 109.

Example

Sample Input 1

1 1

Sample Output 1

3800
In this input, there is only one case. Takahashi will repeatedly submit the code that correctly solves this case with 1⁄2 probability in 1900 milliseconds.

The code will succeed in one attempt with 1⁄2 probability, in two attempts with 1⁄4 probability, and in three attempts with 1⁄8 probability, and so on.

Thus, the answer is 1900×1⁄2+(2×1900)×1⁄4+(3×1900)×1⁄8+…=3800.

Sample Input 2

10 2

Sample Output 2

18400
The code will take 1900 milliseconds in each of the 2 cases, and 100 milliseconds in each of the 10−2=8 cases. The probability of the code correctly solving all the cases is 1⁄2×1⁄2=1⁄4.

Sample Input 3

100 5

Sample Output 3

608000

题意:有一个问题,其中有 n 个样例,经过一次提交后有 m 个样例 TLE,现在重新修改代码,使得超时的 m 个题目都在 1900ms 内以二分之一的概率解决,且其他 n-m 个问题能在 100ms 内解决,求时间期望

思路:

时间=1900*m+100*(n-m),过题的概率是 \frac{1}{2^m},那么期望是 \sum k*p^k,其中 k 是提交次数 

Source Program

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cstring>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<utility>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#define EPS 1e-9
#define PI acos(-1.0)
#define INF 0x3f3f3f3f
#define LL long long
const int MOD = 1E9+7;
const int N = 100000+5;
const int dx[] = {-1,1,0,0,-1,-1,1,1};
const int dy[] = {0,0,-1,1,-1,1,-1,1};
using namespace std;
int vis[N];
int main() {
    int n,m;
    scanf("%d%d",&n,&m);
    LL res=(1900*m+100*(n-m))*(1<<m);
    printf("%lld\n",res);
    return 0;
}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值