All pastes #240712 Raw Edit

Someone

public text v1 · immutable
·published 2006-11-05 21:35 UTC
rendered paste body
#include <iostream>

int main() {
	int S = 4;
	int L = 6;
	float p = 1.0/3.0;
	float f[5][7];
	
	for(int s = 0; s <= S; s++)
		f[s][1] = 1.0;
	for(int l = 1; l <= L; l++) 
		f[0][l] = 1.0;

	for(int s = 1; s <= S; s++)
		for(int l = 1; l <= L; l++) {
			if(l == 1)
				f[s][l] = p * f[s-1][l];
			else
				f[s][l] = p * f[s-1][l] + (1-p) * f[s][l-1];
		}

	std::cout << f[4][6] << std::endl;
}