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

终于AC了!WA了好几次,原来数组开小了

Posted by julyflame at 2009-02-27 18:51:51 on Problem 3629
#include<iostream>
#include <algorithm> 
using namespace std;
int main()
{
	int n,k,p,a[100005],b[60000];
	int i,j,m,temp,ds;
	cin>>n>>k>>p;
	i=1;j=0;temp=0;ds=1;
	m=k/n;
	for(i=1;i<=k;i++)
		a[i]=i;
	a[0]=0;a[1]=0;
	for(i=2;j<m;i++){
		if(a[i]){
			temp++;			
			if(temp==p+1){
				temp=0;
				ds++;		
				if(ds==n){
					b[j]=a[i];j++;
					ds=0;
				}
				a[i]=0;	
			}
		}
		if(i==k)
			i=1;
	}
	sort(b,b+m);
	for(j=0;j<m;j++)
		cout<<b[j]<<endl;
}

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