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

Re:一年了,妹子的终于过了!附代码

Posted by BENCJL at 2015-08-02 12:12:24 on Problem 1002
In Reply To:一年了,妹子的终于过了!附代码 Posted by:woshiliyiyiyiyi at 2012-08-17 17:43:47
我的也类似。。。就是数组开到10000000有点内个。。

#include <iostream>			//AC
#include <cstdio>
#include <string>
#include <cstring>
#include <iomanip>
#include <cstdlib>

using namespace std;

int bucket[10000000];
int mapping[120];

void initialMapping()
{
	mapping['0']=0;mapping['1']=1;mapping['2']=2;
	mapping['3']=3;mapping['4']=4;mapping['5']=5;
	mapping['6']=6;mapping['7']=7;mapping['8']=8;
	mapping['9']=9;
	
	mapping['A']=2;mapping['B']=2;mapping['C']=2;
	mapping['D']=3;mapping['E']=3;mapping['F']=3;
	mapping['G']=4;mapping['H']=4;mapping['I']=4;
	mapping['J']=5;mapping['K']=5;mapping['L']=5;
	mapping['M']=6;mapping['N']=6;mapping['O']=6;
	mapping['P']=7;mapping['R']=7;mapping['S']=7;
	mapping['T']=8;mapping['U']=8;mapping['V']=8;
	mapping['W']=9;mapping['X']=9;mapping['Y']=9;
}

int getNumber(char s[])
{
	int num=0;
	int j=0;
	for(int i=0;i<7;i++)
	{
		while(s[j]=='-')	j++;
		
		num=num*10+mapping[s[j]];
		j++; 
	}
	return num;
}

int main()
{
	int T,phoneNum;
	char s[50];
	
	for(int i=0;i<10000000;i++)
	{
		bucket[i]=0;
	}
	initialMapping();
	
	scanf("%d",&T);
	while(T--)
	{
		scanf("%s",&s);
		
		phoneNum=getNumber(s);
		bucket[phoneNum]++;
	}
	
	bool found=false;
	for(int i=0;i<10000000;i++)
	{
		if(bucket[i]>1)
		{
			printf("%03d-%04d %d\n",i/10000,i%10000,bucket[i]);
			found=true;
		}
	}
	if(found==false)	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