SPOJ 2002. Random Number Generator

Brief description :

求n個產生隨機數的區間 [-Xi, Xi] 的總和 s 落在給定區間[a, b]上的概率。
( 0< Xi <= 10, n <= 10)

Analyse :

http://www.cppblog.com/jifeifei1989/archive/2009/10/05/97890.html

/*
    Author : xiaodao
    Prob : SPOJ 2002. Random Number Generator
    Statuts : Accepted
    Tags : 單形
*/
#include 
#include 
#include 
using namespace std;
const int N = 10, M = 1<>= 1;
    }
    return c;
}

void init(){
    F[1] = 1; for (int i=2;i<=N;i++) F[i] = F[i-1] * i;
    for (int i=0,j=1;i<=N;i++,j*=2) P[j] = i;
}

void input(){
    scanf("%d%lld%lld", &n, &a, &b);
    if (a>b) swap(a, b);

    sum = 0; vol = 1;
    for (int i=0;i q) a -= X[j], b -= X[j];
        else a += X[j], b += X[j];
        ans += sign * (pow(b, n) - pow(a, n));
    }

    ans /= vol; ans /= F[n];
}


int main(){
    //freopen("in.txt", "r", stdin);
    init(); int T; cin >> T;
    while (T--){
        input(); solve();
        printf("%.9f\n", ans);
    }
}