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 345362131 at 2005-07-22 21:24:07 on Problem 2493
#include <stdio.h>
#include <map>
#include <string>
#include <algorithm>           
using namespace std;
int main()
{
	long int T,m,n,i,j,zain,sss,k=0;  
	char s[101],ch;
    map<string,int> ss,flag;
	map<string,int>::iterator ite1,ite2;                                  
	scanf("%d",&T);
	while(T--){
	    scanf("%d",&m);
        for(i=0;i<m;++i){
			scanf("%s",&s);
			for(j=0;j<strlen(s);++j)
				if(s[j]>=65&&s[j]<=90)  s[j]+=32;
			if(strlen(s)>2) sort(s+1,s+strlen(s)-1);
			++ss[s];
		}                                             
		scanf("%d",&n);
		getchar();
        sss=0; 
		while(n--){
			i=0;
			while(ch=getchar()){
				if(ch>=65&&ch<=90)   ch+=32;
		        if(ch!=' '&&ch!='\n')  s[i++]=ch;
				else{
				    s[i]='\0';
					if(strlen(s)>2) sort(s+1,s+strlen(s)-1);
					++flag[s];                   
					i=0;
					if(ch=='\n')  break;
				}
			}                                                                        
			if(sss==0) {
				printf("Scenario #%d:\n",++k);
			    sss=1;
			}  
			zain=1;   
			for(ite2=flag.begin();ite2!=flag.end();++ite2){	  	  
				ite1=ss.find(ite2->first);
				if(ite1!=ss.end()){
					j=ite2->second;
					while(j--){
					    zain*=(ite1->second);
					}
				}
				else{
				    zain=0;
					break;
				}
			}
			flag.clear();
			printf("%d\n",zain);
		}
		printf("\n");
		ss.clear();
	}
    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