Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

只要一个数组就行了!附代码!

Posted by woshiliyiyiyiyi at 2012-08-17 09:34:02 on Problem 3370
#include<stdio.h>
#define N 100015

int flag[N];

int main()
{
	int i, sum, j, a;
	int count, n, t;

	while (fscanf(stdin, "%d %d", &count, &n) != EOF)
	{
		for (i=1; i<=count; i++)
			flag[i] = 0;

		sum = 0;
		for (i=1; i<=n; i++)
		{
			fscanf(stdin, "%d", &a);
			sum += a;
			t = sum %count;
			sum = sum %count;

			if (!t)
			{
				for (j=1; j<=i; j++)
					printf("%d ", j);
				break;
			}
			else
			{
				if (flag[t] > 0)
				{
					for (j=flag[t]+1; j<=i; j++)
						printf("%d ", j);
					break;
				}
			}
			flag[t] = i;
		}
		for (j=i+1; j<=n; j++)
			fscanf(stdin, "%d", &sum);
		printf("\n");
	}

	return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator