?? 1054.cpp
字號(hào):
/* This Code is Submitted by wywcgs for Problem 1054 on 2006-01-07 at 00:26:13 */
#include <cstdio>
#include <algorithm>
using namespace std;
const int MAX = 64;
const int TOTAL = 2560;
bool chose[TOTAL];
void little(int&, int);
int main()
{
int n, m, self[MAX];
int i, case_no;
for(case_no = 1; scanf("%d %d", &n, &m) != EOF && n*m != 0; case_no++) {
memset(chose, false, sizeof(chose));
for(i = 0; i < m; i++) {
scanf("%d", &self[i]);
chose[self[i]] = true;
}
int t = 1, h = n*m, win = 0;
sort(self, self+m);
for(i = m-1; i >= 0; i--) {
while(chose[h]) h--;
if(h > self[i]) chose[h] = true, little(t, n-2);
else win++, little(t, n-1);
}
printf("Case %d: %d\n", case_no, win);
}
return 0;
}
void little(int& t, int n)
{
int c = 0;
while(c < n) {
while(chose[t]) t++;
chose[t] = true; c++;
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -