南阳热身赛B——模拟——New Years Eve

模拟水题

/************************************************
* Author        :Powatr
* Created Time  :2015/10/21 12:53:05
* File Name     :B.cpp
 ************************************************/

#include <cstdio>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <cstring>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <bitset>
#include <cstdlib>
#include <ctime>
using namespace std;

#define lson l, mid, rt << 1
#define rson mid + 1, r, rt << 1 | 1
typedef long long ll;
const int MAXN = 1e6;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;

double a[MAXN], b[MAXN];
int main(){
    int T;
    int B, L , N;
    scanf("%d", &T);
    while(T--){
        scanf("%d%d%d", &B, &L, &N);
        memset(b, 0, sizeof(b));
        memset(a, 0, sizeof(a));
        int sum = 750 * B;
            a[1] = sum;
          if(L == 1)  b[1] = sum;
            for(int i = 1; i < L; i++){
                memset(b, 0, sizeof(b));
                for(int j = 1; j <= i; j++){
                    for(int k = 1; k <= j; k++){
                        int id = j*(j-1)/2 + k;
                        b[id] += max(0.0, a[id]-250)/3;
                        b[id+j] += max(0.0, a[id]-250)/3;
                        b[id+j+1] += max(0.0, a[id]-250)/3;
                    }
                }
                for(int j = 1; j <= i+1; j++){
                    for(int k = 1; k <= j; k++){
                        int id = j*(j-1)/2 + k;
                        a[id] = b[id];
                        }
                    }
                }
            for(int j = 1; j <= L*(L+1)/2; j++)
                if(b[j] > 250) b[j] = 250;
       printf("%.7f\n", b[N]);
    }
    return 0;
}
              

  

posted @ 2015-10-21 14:07  Painting、时光  阅读(164)  评论(0编辑  收藏  举报