poj3445

简单题

View Code
#include < iostream >
#include
< cstdio >
#include
< cstdlib >
#include
< cstring >
using namespace std;

string st[ 16 ];
int length[ 16 ];
char a[ 6000000 ];

int getid( char * a)
{
int len = strlen(a);
for ( int i = 0 ; i <= 15 ; i ++ )
if (len == length[i])
return i;
return - 1 ;
}

int main()
{
// freopen("t.txt", "r", stdin);
st[ 0 ] = " {} " ;
length[
0 ] = 2 ;
for ( int i = 1 ; i <= 15 ; i ++ )
{
st[i]
= " { " + st[ 0 ];
for ( int j = 1 ; j < i; j ++ )
st[i]
+= " , " + st[j];
st[i]
+= " } " ;
length[i]
= st[i].length();
}
int t;
scanf(
" %d " , & t);
while (t -- )
{
scanf(
" %s " , a);
int x = getid(a);
scanf(
" %s " , a);
int y = getid(a);
cout
<< st[x + y] << endl;
}
return 0 ;
}

你可能感兴趣的:(poj)