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 lzxzy at 2018-08-27 11:52:45 on Problem 1002 and last updated at 2018-08-27 20:14:46
#include <cstdio>
#include <cstring>
using namespace std;
int n,sum;
int Sort[10000000];
char ch[15];
bool flag=0;

int pd(char x)
{
	switch(x)
	{
		case 'A':return 2;
		case 'B':return 2;
		case 'C':return 2;
		case 'D':return 3;
		case 'E':return 3;
		case 'F':return 3;
		case 'G':return 4;
		case 'H':return 4;
		case 'I':return 4;
		case 'J':return 5;
		case 'K':return 5;
		case 'L':return 5;
		case 'M':return 6;
		case 'N':return 6;
		case 'O':return 6;
		case 'P':return 7;
		case 'R':return 7;
		case 'S':return 7;
		case 'T':return 8;
		case 'U':return 8;
		case 'V':return 8;
		case 'W':return 9;
		case 'X':return 9;
		case 'Y':return 9;
		default:return 0;
	}
}

void into()
{
	int len;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%s",ch);
		len=strlen(ch);
		sum=0;
		for(int j=0;j<len;j++)
		{
			if(ch[j]=='-')continue;
			if(ch[j]=='Q' || ch[j]=='Z')continue;
			if(ch[j]>='0' && ch[j]<='9')sum=sum*10+ch[j]-48;
			if(ch[j]>='A' && ch[j]<='Z')sum=sum*10+pd(ch[j]);
		}
		if(sum>=10000000)continue;//对排序进行维护
		Sort[sum]++;//计数排序
	}
}

int main()
{
	into();
	for(int i=0;i<=9999999;i++)//从零开始循环
		if(Sort[i]>1)
		{
			printf("%03d-%04d %d\n",i/10000,i%10000,Sort[i]);//注意输出前导零
			flag=1;
		}
	if(!flag)printf("No duplicates.\n");
	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