F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Two Brothers

Time Limit: 6000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 713    Accepted Submission(s): 63


Problem Description
Though Yueyue and Lele are brothers , they are very different.
For example, Yueyue is very hard in study, especially in writing compositions. To make the composition looks nice , he will not use the same word twice. While Lele is very lazy, and he sometimes copys his brother's homework.

Last week, their teacher asked them to write a composition named "My Mother", they handed the same composition. The teacher was very angry , but Lele just answered "We have the same mother , why should our compositions be different ?"

Now,the teacher is asking Yueyue and Lele to write the compositions again, and he wants to calculate the length of longest common subsequence of words occuring in the two compositions. Can you help him ?
 

Input
There will be many test cases in the problem.Please process to the end of file.
Each case contains two lines.
The first line means Yueyue's composition and the second line means Lele's composition.
Each composition will contains no more than 10^4 words . And each word will contains less than 40 characters.Each character will only be in a~z or A~Z.
Two words will be separated by a blank.

To make the problem easier, there will be a "#" at the end of each composition.
 

Output
For each case , output a integer in a line represents the length of longest common subsequence of words occuring in the their compositions.
 

Sample Input
aa bb cc # aa cc bb #
 

Sample Output
2
 

Hint
Huge input,the C function scanf() will work better than cin
 

Author
linle
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-04-30 14:56:51, Gzip enabled