Description
从区间[a,b]中选一个数x,然后把x个卢布放在一个信封里,把2x个卢布放在另一个信封里,现在打开了一个信封里面有c个卢布,问是拿手中这个信封还是拿另一个信封使得能够拿到的卢布的期望最大
Input
三个整数a,b,c(1<=a,b,c<=1e9)
Output
如果拿手中这个信封能够得到的卢布数量期望大就输出Stay with this envelope,否则输出Take another envelope
Sample Input
3 5 3
Sample Output
Take another envelope
Solution
如果c>b,那么说明c=2x,显然拿这个;
如果c<=b,那么有两种情况:
1.如果2a>b,说明c必然是x,否则c=2*x>b矛盾,所以拿另一个
2.如果2a<=b,那么c=2x的方案数是x属于区间[a,b/2],c=x的方案数是x属于[b/2+1,b],显然c=x的概率更大,所以还是拿另一个
Code
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<ctime>
using namespace std;
typedef long long ll;
#define INF 0x3f3f3f3f
#define maxn 1111
int main()
{
int a,b,c;
while(~scanf("%d%d%d",&a,&b,&c))
{
if(c>b)printf("Stay with this envelope\n");
else printf("Take another envelope\n");
}
return 0;
}