#include <stdio.h>

#define NUM_DELNIS 4
static interDist = 20;	/* delay between DELNIs */
static sameSpace = 1;		/* delay between hosts on the same DELNI */
#define maxNNodes 1024

int main(int argc, char *argv[])
{
	static int delni[NUM_DELNIS],	/* count of hosts at this delni */
		hostAt[maxNNodes];			/* which delni is this host at? */
	int whichDelni = 0, i, j, NNodes, ThinkTime;

	if(argc != 4)
	{
		fprintf(stderr, "Usage: %s NNodes sameSpace interDelniDist\n", argv[0]);
		exit(1);
	}

	NNodes = atoi(argv[1]);
	sameSpace = atoi(argv[2]);
	interDist = atoi(argv[3]);

	/* spread them out evenly across Delnis */
	for(i=0; i< NNodes; i++)
		delni[i%4]++;

	/* now record which delni each host is at */
	for(i=0; i < NNodes; i++)
	{
		hostAt[i] = whichDelni;
		if(--delni[whichDelni] == 0)
			whichDelni++;
	}
	
	for(i=0; i < NNodes - 1; i++)
	{
		for(j=i+1; j<NNodes; j++)
			if(hostAt[i] == hostAt[j])
				printf("%d ", sameSpace);
			else
				printf("%d ", 2*sameSpace + interDist * (hostAt[j]-hostAt[i]));
		printf("\n");
	}
	return 0;
}

