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 ziliang at 2007-11-11 17:00:15 on Problem 2356
In Reply To:re 是为什么 Posted by:y05zh at 2007-11-11 16:02:03
> #include<iostream>
> using namespace std;
> #define N (100000+10)
> int a[N];
> int b[N];
> int sum[N];
> int n;
> void solve()
> {
> 	int i;
> 	sum[0]=a[0];
> 	sum[0]%=n;
> 	for(i=1;i<n;i++)
> 	{
> 		sum[i-1]%=n;
> 		sum[i]=sum[i-1]+a[i];
> 	}
> 	sum[i-1]%=n;
> 
> 	memset(b,0,sizeof(b));
> 	int flag=0;
> 	int bb,e;
> 	for(i=0;i<n;i++)
> 	{
> 		if(sum[i]%n==0)
> 		{
> 			flag=1;
> 			bb=0;
> 			e=i;
> 			break;
> 		}
> 	}
> 	if(flag==0)
> 	{
> 		for(i=0;i<n;i++)
> 		{
> 			int t=sum[i]%n;
> 			if(b[t]==0)
> 			{
> 				b[t]=i;
> 			}
> 			else
> 			{
> 			//	flag=1;
> 				bb=b[t];
> 				e=i;
> 				break;
> 			}
> 		}
> 	}
> 	if(flag==1)
> 	{
> 		printf("%d\n",e+1);
> 		for(i=0;i<=e;i++)
> 		printf("%d\n",a[i]);
> 
> 	}
> 	else
> 	{
> 		printf("%d\n",e-bb);
> 		for(i=bb+1;i<=e;i++)
> 		{
> 			printf("%d\n",a[i]);
> 		}
> 	}
> 
> }
> void main()
> {
> 	int i;
> //	freopen("in.txt","r",stdin);
> //	freopen("out.txt","w",stdout);
> //	while(
> 		scanf("%d",&n);//!=EOF)
> 	{
> 		for(i=0;i<n;i++)
> 		{
> 			scanf("%d",&a[i]);	
> 		}
> 		solve();
> 	}
> }

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