int rand_idx(double *p, int n)
{
	double s = rand() / (RAND_MAX + 1.0);
	int i;
	for (i = 0; i < n - 1 && (s -= p[i]) >= 0; i++);
	return i;
}

int main()
{
	int user_action, my_action;
	int user_rec[] = {0, 0, 0};
	const char *names[] = { , ,  };
	char str[2];
	const char *winner[] = { , ,  };
	double  p[LEN] = { 1./3, 1./3, 1./3 };

	while (1) {
		my_action = rand_idx(p,LEN);

		printf(
			);

		
		if (!scanf(, &user_action)) {
			scanf(, str);
			if (*str == 'q') {
				printf(,user_rec[0],user_rec[1], user_rec[2]); 
				return 0;
			}
			continue;
		}
		user_action --;
		if (user_action > 2 || user_action < 0) {
			printf();
			continue;
		}
		printf(,
			names[user_action], names[my_action],
			winner[(my_action - user_action + 3) % 3]);

		user_rec[user_action]++;
	}
}