| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
我感觉不用记“,”的数,而直接打表就可以。以下是自己得代码#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator