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 zpdlut at 2009-02-06 21:10:14 on Problem 1002
In Reply To:~~呵呵·原来这样改~也能过~ Posted by:luketyg at 2009-01-10 19:33:23
> #include "iostream"
> #include "algorithm"
> using namespace std;
> struct data
> {
> 	int count;
> 	int a;
> 	char b[8];
> };
> int map(char x)
> {
> 	if(x>='0'&&x<='9')
> 		return x-'0';
> 	else if(x>='A'&&x<='P')
> 		return (x-'A')/3+2;
> 	else if(x>='R'&&x<='Y')
> 		return (x-'Q')/3+7;
> }
> int Turn(char *str,char *b)
> {
> 	int Exp=1000000,s=0,k=0;
> 	size_t i;
> 	for(i=0;i<strlen(str) ;i++)
> 	{
> 		if(str[i]!='-')
> 		{
> 			if(k==3)b[k++]='-';
> 			b[k++]=map(str[i])+'0';
> 			s+=Exp*map(str[i]);
> 			Exp/=10;
> 		}
> 	}
> 	b[k]='\0';
> 	return s;
> }
> bool Cmp(const data &a,const data &b)
> {
> 	if(a.a<b.a)return 1;
> 	else return 0;
> }
> int main()
> {
> 	int t,i;
> 	cin>>t;
> 	char (*str)[10]=new char[t][10];
> 	data *d=new data[t];
> 	for(i=0;i<t;i++)
> 	{
> 		scanf("%s",str[i]);       //不用cin输入就过了否则超时~哎!!汗~~
> 		d[i].a=Turn(str[i],d[i].b);
> 		d[i].count=1;
> 	}
> 	sort(d,d+t,Cmp);
> 	int now=d[0].a,k=0;
> 	for(i=1;i<t;i++)
> 	{
> 		if(now==d[i].a)d[k].count++;
> 		else {now=d[i].a;k=i;}
> 	}
> 	int flag=0;
> 	for(i=0;i<t;i++)
> 		if(d[i].count!=1)
> 		{
> 			for(int j=0;j<8;j++)
> 				cout<<d[i].b[j];
> 			cout<<" "<<d[i].count<<endl;
> 			now=d[i].count;
> 			flag=1;
> 		}
> 		if(flag==0)cout<<"No duplicates."<<endl;
> 	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