程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 更多編程語言 >> 編程解疑 >> numbers-Jack and Jills Compact Discs

numbers-Jack and Jills Compact Discs

編輯:編程解疑
Jack and Jill's Compact Discs

Description
Jack and Jill have decided to sell some of their Compact Discs, while they still have some value. They have decided to sell one of each of the CD titles that they both own. How many CDs can Jack and Jill sell?

Neither Jack nor Jill owns more than one copy of each CD.

Input
The input consists of a sequence of test cases. The first line of each test case contains two non-negative integers N and M, each at most one million, specifying the number of CDs owned by Jack and by Jill, respectively. This line is followed by N lines listing the catalog numbers of the CDs owned by Jack in increasing order, and M more lines listing the catalog numbers of the CDs owned by Jill in increasing order. Each catalog number is a positive integer no greater than one billion. The input is terminated by a line containing two zeros. This last line is not a test case and should not be processed.

Output
For each test case, output a line containing one integer, the number of CDs that Jack and Jill both own.

Sample Input
3 3
1
2
3
1
2
4
0 0

Sample Output
2

最佳回答:


http://blog.csdn.net/u010372095/article/details/9004723

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved