Here is a more efficient algorithm for solving it, it can solve past 100 dice with 100 sides instantly. It doesn't work much past that due to overflow, however you can fix this by changing the type of v, sum, total to a big integer or big decimal. Here is the java code, you can download compiled version at
http://wam.umd.edu/~darreon/dice To run, download and at the command line go to its directory and type java dice2 8 6 4 (for n = 8, s = 6, r = 4). BTW does anyone know of any open jobs doing this kind of programming? I need a job and this stuff is fun :)
public class dice2 {
public static void main(String [] args) {
System.out.println(solver(atoi(args[0]), atoi(args[1]), atoi(args[2])));
}
static double solver(int n, int s, int r) {
double v = 1, sum = 0, total = 0;
int t = n, t2 = n * s;
for(int i=1; t<t2; i++, t++, t2--) {
sum += (reduce(t, r) + reduce(t2, r)) * v;
total += 2 * v;
v = v / i * t;
}
if(t == t2) { sum += reduce(t, r) * v; total += v; }
return (double)sum/total;
}
static int reduce(int x, int r) { return x < r ? 0 : x - r; }
static int atoi(String s) { return (int) (Long.decode(s)).longValue(); }
}