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 20083331 at 2009-04-25 23:15:39 on Problem 3445
#include<iostream>
#include<cstring>
using namespace std;

char str[16][83000];
char input[2][83000];

int main()
{
strcpy(str[0],"{}");
strcpy(str[1],"{{}}");
int i,j;
for(i=2;i<=15;i++)
{
	str[i][0]='{';
	for(j=0;j<i-1;j++)
	{
		strcat(str[i],str[j]);
		strcat(str[i],",");
	}
	strcat(str[i],str[i-1]);
	strcat(str[i],"}");
}

int n;
cin>>n;
for(i=0;i<n;i++)
{
	cin>>input[0]>>input[1];
	int a,b;
	for(j=0;j<=15;j++)
	{
		if(strcmp(input[0],str[j])==0)
			a=j;
		if(strcmp(input[1],str[j])==0)
			b=j;
	}
//	cout<<"a=   "<<a<<b<<endl;
	cout<<str[a+b]<<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