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

我这个通过了usaco数据的程序怎么交不过啊

Posted by lunatic at 2007-08-11 10:21:53 on Problem 3046
狂汗!有什么trick?

#include <cstdio>
#include <cstring>
const int MaxN = 100000 + 10, MaxM = 100;
const int MOD = 1000000;
int Sum[MaxN], F[MaxN], G[MaxN];
int Total[MaxM];

int Sumup(int i, int j) {
	if (i <= 0) return Sum[j];
	else return (Sum[j] - Sum[i - 1] + MOD) % MOD;
}
int main() {
	int N, M, Left, Right, x, i, j;
	scanf("%d%d%d%d", &N, &M, &Left, &Right);
	for (i = 0; i < M; i ++) {
		scanf("%d", &x);
		Total[x - 1] ++;
	}
	F[0] = 1;
	for (j = 0; j <= M; j ++) Sum[j] = 1;
	for (i = 0; i < N; i ++) {
		for (j = 0; j <= M; j ++)
			G[j] = Sumup(j - Total[i], j);
		for (j = 1; j <= M; j ++)
			Sum[j] = (G[j] + Sum[j - 1]) % MOD;
		memcpy(F, G, sizeof(G));
	}
	printf("%d\n", Sumup(Left, Right));
	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