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

我的解答250MS

Posted by yubo555123 at 2010-07-26 22:31:10 on Problem 1002 and last updated at 2010-07-27 12:06:17
大家好,小弟我初来乍到,刚做了这题 AC了  给大家看下我的代码  大家给小弟我多指点指点哈~谢谢各位大虾了~~~~~
我的邮箱是yubo555123@126.com 欢迎同道中人共同探讨 共同进步!!
小弟给大家鞠躬啦~~~

这题只要按顺序存好最后来一次排序 再按顺序计算重复的有几个就欧拉~!时间只用了250MS^_^
#include <stdio.h>
#include <algorithm>
using namespace std;
int main()
{
	int n;
	char s[80];
	int a[100000];
	int i,k;
	int c = 0;
	int f,g=1;

	scanf("%d", &n);
	getchar();
	for(k=0; k<n; ++k)
	{
		int u = 0;
		int f = 0;

		gets(s);
		for (i=0; s[i]!='\0'; ++i)
		{
			switch (s[i])
			{
			case 'A':
			case 'B':
			case 'C':
				u = u*10+2;
				break;
			case 'D':
			case 'E':
			case 'F':
				u = u*10+3;
				break;
			case 'G':
			case 'H':
			case 'I':
				u = u*10+4;
				break;
			case 'J':
			case 'K':
			case 'L':
				u = u*10+5;
				break;
			case 'M':
			case 'N':
			case 'O':
				u = u*10+6;
				break;
			case 'P':
			case 'R':
			case 'S':
				u = u*10+7;
				break;
			case 'T':
			case 'U':
			case 'V':
				u = u*10+8;
				break;
			case 'W':
			case 'X':
			case 'Y':
				u = u*10+9;
				break;
			default:
				if (s[i]>='0' && s[i]<='9')
					u = u*10+s[i]-48;
			}
		}

		a[k] = u;
	}

	sort(a, a+n);
	f = a[0];
	for (i=1; i<n; ++i)
	{
		if (a[i] == f)
			++g;
		else 
		{
			if (g != 1)
			{
				printf("%03d-%04d %d", f/10000, f%10000, g);
				printf("\n");
				c = 1;
			}
			f = a[i];
			g = 1;
		}
	}

	if (g != 1)
	{
		printf("%03d-%04d %d", f/10000, f%10000, g);
		c = 1;
	}

	if (!c)
		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