记录编号 444591 评测结果 AAAAAAAAA
题目名称 [SYZOI Round1]组合数 最终得分 100
用户昵称 GravatarHeHe 是否通过 通过
代码语言 C++ 运行时间 0.004 s
提交时间 2017-09-03 14:44:43 内存使用 0.60 MiB
显示代码纯文本
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;

inline char getc(void) { 
    static char buf[1 << 18], *fs, *ft;
    return (fs == ft && (ft = (fs = buf) + fread(buf, 1, 1 << 18, stdin)), fs == ft) ? EOF : *fs++;
}

inline int read(void) { 
    register int res = 0;
    register char tmp = getc();
    while(!isdigit(tmp)) tmp = getc();
    while(isdigit(tmp))
        res = ((res + (res << 2)) << 1) + (tmp ^ 0x30),
        tmp = getc();
    return res;
}

int N, L, R;
int s[110], sum;
long long f[4510], cnt1, cnt2;

int main() { 
#ifndef LOCAL
    freopen("conbination.in", "r", stdin);
    freopen("conbination.out", "w", stdout);
#endif
    N = read();
    for(int i = 1; i <= N; ++i) s[i] = read();
    L = read(), R = read();
    for(int i = 1; i <= N; ++i) { 
        sum += s[i];
        for(int j = sum; j > s[i]; --j)
            f[j] += f[j - s[i]];
        f[s[i]] += 1;
    }
    f[0] = 1;
    for(int i = 0; i <= sum; ++i) { 
        if(i >= L && i <= R) cnt1 += f[i];
        cnt2 += f[i];
    }
    printf("%.4lf", cnt1 * 1.0 / cnt2);
    return 0;
}