HDU 1247

简介: Hat’s Words Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 3779    Accepted Submission(s): 1...

Hat’s Words

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 3779    Accepted Submission(s): 1432


Problem Description
A hat’s word is a word in the dictionary that is the concatenation of exactly two other words in the dictionary.
You are to find all the hat’s words in a dictionary.
 

 

Input
Standard input consists of a number of lowercase words, one per line, in alphabetical order. There will be no more than 50,000 words.
Only one case.
 

 

Output
Your output should contain all the hat’s words, one per line, in alphabetical order.
 

 

Sample Input
a ahat hat hatword hziee word
 

 

Sample Output
ahat hatword
 1 //大致题意: 判断一个单词是否由其他两个单词组成 
 2 #include <iostream>
 3 #include <vector>
 4 #include <string>
 5 #include <cstring>
 6 #include <map>
 7 using namespace std;
 8 int main()
 9 {
10     int i,j,k;
11     string s="";
12     vector <string > v;
13     map <string ,int > mm;
14     while(cin>>s)
15     {
16         v.push_back(s);
17         mm[s]++;//不为0表示存在 
18         s.clear();
19     }
20     for(i=0;i<v.size();i++)
21     {
22         string s1="";
23         s1=v[i];
24         string s2 = "";//不可放在内层 
25         for(j=0;j+1<s1.size();j++)
26         {
27             s2 += s1[j];
28             string s3 = s1.substr(j+1);
29             if(mm[s2]&&mm[s3])
30             {
31                 cout<<s1<<endl;
32                 s2.clear();
33                 break;//可能一个单词有多种匹配,满足一种输出即可 
34             }
35         }
36     }
37     system("pause");
38     return 0;
39 }
40                 
41             
42             

 

目录
相关文章
|
人工智能 Java
hdu 1712 ACboy needs your help
ACboy这学期有N门课程,他计划花最多M天去学习去学习这些课程,ACboy再第i天学习第j门课程的收益是不同的,求ACboy能获得的最大收益。
113 0
|
人工智能 Java 安全
HDU 1039 Easier Done Than Said?
Easier Done Than Said? Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 12751    Accepted Subm...
780 0
|
人工智能
|
机器学习/深度学习
|
机器学习/深度学习 人工智能
|
机器学习/深度学习 人工智能
HDU 2674
  题意:求N!mod2009,N=41时,N!因式分解一定含7*7*41,即N!%2009=0.所以只要计算0
693 0