本文主要是介绍UVA 10900 So you want to be a 2n-aire?,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
题意:参考这里点击打开链接#include<stdio.h>
#include<string.h>
#include<math.h>
#define MAXD 35
int N;
double T, q[MAXD];
void solve()
{int i, j, k;double eq, f = 1, quit;f = q[N];for(i = N - 1; i >= 0; i --){quit = q[i];eq = quit / f;if(eq <= T)f = (T + 1) / 2 * f;elsef = (eq - T) / (1 - T) * quit + (1 - eq) / (1 - T) * (eq + 1) / 2 * f;}printf("%.3lf\n", f);
}
int main()
{q[0] = 1;for(int i = 1; i <= 30; i ++)q[i] = 2 * q[i - 1];for(;;){scanf("%d%lf", &N, &T);if(!N)break;if(fabs(1 - T) < 1e-9)printf("%.3lf\n", q[N]);elsesolve();}return 0;
}
这篇关于UVA 10900 So you want to be a 2n-aire?的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!