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

Why Wrong ! Give me a reason !!!! What data!?

Posted by jesse_luzexi at 2007-04-18 22:15:00 on Problem 2051
#include "iostream"

using namespace std;

char order[11];
int Qnum[1001][2];


int minimum(const void * a,const void * b)
{
	int *c=(int *)a;
	int *d=(int *)b;
	if(c[1]!=d[1])
		return c[1]-d[1];
	else
		return c[0]-d[0];
}


int main ()
{
	int i,j,k;
	int num,m;
    int temp;
	//freopen("in.txt","r",stdin);
	for(num=0;;)
	{
		scanf("%s",order);
		if(order[0]=='#') break;
        if(strcmp(order,"Register")==0)
        {
            scanf("%d%d",&Qnum[num][0],&Qnum[num][1]);
		    //Qnum[num][2]=num;
		    num++;
        }
	}
    temp=sizeof(Qnum[0]);
	qsort(Qnum,num,sizeof(Qnum[0]),minimum);
	scanf("%d",&m);

	for(i=1,j=0;j<m;i++)
	{
        if(j>=m) break;
		for(k=0;k<num;k++)
			if(i%Qnum[k][1]==0)
			{	
				printf("%d\n",Qnum[k][0]);
				j++;
				if(j>=m) break;
			}
	}
	return 1;
}

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