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 |
直接打表吧,一共只有0到15,16个数呢。#include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <climits> using namespace std; char s[16][100000]; int main() { freopen("in.txt","r",stdin); int i,j,ls,num1,num2,n; char s1[100000],s2[100000]; strcpy(s[0],"{}"); for(i=1;i<=15;i++) { s[i][0]='{'; s[i][1]='\0'; for(j=0;j<i-1;j++) { strcat(s[i],s[j]); ls=strlen(s[i]); s[i][ls]=','; s[i][ls+1]='\0'; } strcat(s[i],s[j]); ls=strlen(s[i]); s[i][ls]='}'; s[i][ls+1]='\0'; } scanf("%d",&n); while(n--) { scanf("%s%s",s1,s2); for(i=0;i<=15;i++) { if(strcmp(s1,s[i])==0) { num1=i; } if(strcmp(s2,s[i])==0) { num2=i; } } num1=num1+num2; printf("%s\n",s[num1]); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator