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

help,求测试数据

Posted by beijing123 at 2006-03-17 17:38:07 on Problem 1002
总是wronganswer.迷茫
00548259


# include <stdio.h>
# include <string.h>
# include <stdlib.h>
char inputc[100001][100];
long telenum[100001];
int num[100001];
long duplicatenum[100001];
int compare(const void *a,const void *b) {
	return *(int *)a-*(int *)b;
}


void main(){
	int n,times,i,j,m=0,k=0,l=0,len=0;
	
	scanf("%d",&n);
	int exchange[30]={2,2,2,3,3,3,4,4,4,5,5,5,6,6,6,7,0,7,7,8,8,8,9,9,9};
	
	for(times=0;times<n;times++){//将输入的数经过转换并去掉无用字符存入telenum中
		scanf("%s",inputc[times]);//第times个数
		len=strlen(inputc[times]);
		for(i=0;i<len;i++){
			if((inputc[times][i]>='0')&&(inputc[times][i]<='9')){
				telenum[times]+=long(inputc[times][i]-'0');
				telenum[times]*=10;
			}
			if((inputc[times][i]>='A')&&(inputc[times][i]<='Y')){
				telenum[times]+=long(exchange[inputc[times][i]-'A']);
				telenum[times]*=10;
			}
		}
		telenum[times]/=10;
	}

		qsort((void*)telenum,n,sizeof(int),compare);//把号码按升序排好
	
		i=0;
        for(;i<n;i++){
			for(j=i+1;j<n;j++){
				if(telenum[i]!=telenum[j]){//察看已排好的数,
					num[l]=j-i;
					if(num[l]!=1){m=-1;}
					duplicatenum[l]=telenum[i];
					l++;
					i=j-1;
					if(j==n-1){
						num[l]=1;
						duplicatenum[l]=telenum[j];
					}
					break;
				}
				else if(j==n-1){
						num[l]=j+1-i;
						if(num[l]!=1){m=-1;}
						duplicatenum[l]=telenum[i];
						i=j;
				}
			}
		}
		//当某一个号码的个数不为零的时候,m=-1,否则m==0,No duplicates
		if(m){
			for(j=0;j<=l;j++)
				if(num[j]>1)
						printf("%0.3d-%0.4d %d\n",duplicatenum[j]/10000,duplicatenum[j]%10000,num[j]);
						}
		else printf("No duplicates\n");
}

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