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 CuriousCat at 2016-11-10 17:28:28 on Problem 1323
#include <cstdio>
#include <algorithm>
#define MAX_N 150
using namespace std;
int N, M, A[MAX_N];
int main(int argc,char *argv[]) {
	int T = 0;
	while (scanf("%d%d", &M, &N) == 2 && N * M != 0) {
		++T;
		for (int i = 1;i <= N;++i) scanf("%d",&A[i]);
		sort(A + 1, A + N + 1);
		int pc = N * M + 1, pm = N, b = 0, ans = 0;
		while (--pc >= 1) {
			if (pc == A[pm]) {
				if (b == 0) ++ans; else --b;
				--pm;
			}
			else ++b;
		}
		printf("Case %d: %d\n", T, ans);
	}
	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