Game Simulation

prodesc.gif Problem Description

Suppose there are N people, including you, playing a special card game. At the beginning, each player receives one card. The point of a card is a non negative integer. During a round, any player whose card with a point equals to the sum of the points of OTHER K players survives and advances to the next round. If there are no players advancing or all players advancing ,the game ends and all players in the last round are winners.

Give you the cards each player receives at first, we want to know who are the winners.

prodesc.gif Input

Input contains multiple cases.

The first line contains an integer T representing the number of cases.

Then following T cases.

Each test case starts with two integers N (1 <= N <= 1000),K(1 <= K <= 10) .Then following N integers ,the ith integer Vi (0 <= Vi <= 1000) represents the point of the ith player’s card. There maybe one or more lines between each case.

prodesc.gif Output

For each test case, output one line containing "Case #x: y z", where x is the case number (starting from 1) and y is last round (starting from 1) and z is the number of winners. Then output the z winners in ascending order.

prodesc.gif Sample Input

4

3 2

0 0 0

3 3

0 0 0

5 3

0 0 0 1 1

11 1 3 4 5 1 4 3 3 5 2 5 3

prodesc.gif Sample Output

Case #1: 1 3

1 2 3

Case #2: 1 3

1 2 3

Case #3: 2 2

4 5

Case #4: 2 9

1 2 3 5 6 7 8 10 11

prodesc.gif Hint

In sample 3,round 1,player 4,5 advances to the next round(1=0+0+1).And in round 2, no players advance.So the total rounds is 2,and the winners are player 4 and 5.

#include <stdio.h>
#include <stdlib.h>
int mycmp(const void *a,const void *b)
{
	return *(int *)a-*(int *)b;
}
int main()
{
	int a[1000],k,n;
	int t,round,sum,test,i;
	scanf("%d",&t);
	test=1;
	while(test<=t)
	{
		++test;
		sum=0;
		scanf("%d%d",&n,&k);
		for (i=0;i<n;++i)
		{
			scanf("%d",&a[i]);
		}
		qsort(a,n,sizeof(int),mycmp);












	}
	return 0;
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章