#include <stdio.h>
#include <stdlib.h>
#include <string.h>

const int max_decks = 32;

int num_ties[max_decks][3];

int main() {
	int permutations[24][4] = {
	{1,2,3,4},
	{1,2,4,3},
	{1,3,2,4},
	{1,3,4,2},
	{1,4,2,3},
	{1,4,3,2},
	{2,1,3,4},
	{2,1,4,3},
	{2,3,1,4},
	{2,3,4,1},
	{2,4,1,3},
	{2,4,3,1},
	{3,1,2,4},
	{3,1,4,2},
	{3,2,1,4},
	{3,2,4,1},
	{3,4,1,2},
	{3,4,2,1},
	{4,1,2,3},
	{4,1,3,2},
	{4,2,1,3},
	{4,2,3,1},
	{4,3,1,2},
	{4,3,2,1}
	};
	memset(num_ties, 0, sizeof(num_ties));
	int tries = 0;
	while (tries < 1000000) {
		int guys[4] = {0,0,0,0};
		int decks = 0; 
		for (decks = 0; decks < max_decks; decks++ ) {
			int * row = permutations[rand() % 24];
			int i = 0;
			int max = 0;
			int maxcount = 1;
			for (i = 0; i < 4; ++i) {
				guys[i] += row[i];
				if (max == guys[i]) {	
					++maxcount;
				} else if (max < guys[i]){
					max = guys[i];
					maxcount = 1;
				}

			}
			while (--maxcount > 0) num_ties[decks][maxcount - 1] ++;
		}
		++tries;
	}
	for (int decks = 0; decks < max_decks; decks++) {
		printf("%d: %f  %f  %f\n", decks+1, 
			float(num_ties[decks][0]) / tries,
			float(num_ties[decks][1]) / tries,
			float(num_ties[decks][2]) / tries
		);
	}
}
