Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
最开始想麻烦了。。。底下有代码, 希望自己想的就别点了。。。#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator