On the first line, integers N and M are given separated by a single space. On the second line, N integers are given, and on the third line, M integers are given, each separated by single spaces.
Output, on one line, how many distinct numbers appear in both sequences. No matter how many times a number appears, count it as one type.
For example, for 1 2 3 and 2 3 4, the common numbers are 2 and 3, so output 2.
Constraints
1 ≤ N, M ≤ 100, 0 ≤ each element ≤ 1000
Input example 1
3 3
1 2 3
2 3 4Output example 1
2Input example 2
2 2
1 2
3 4Output example 2
0What you'll train
State the constraints
What you get
How to ask the AI
Clearly tell the AI that even if the same number appears multiple times, it should be counted as one type. Also remember to mention that if there are no common numbers at all, the output should be 0.
If you ask vaguelyThe AI may simply count the number of matching elements without accounting for duplicates, resulting in code that returns the number of occurrences rather than the number of distinct values.
あなたのコード
プレビュー
AIレビュー(プロンプト練習)
コードはChatGPTやClaudeに出させたものを貼って構いません。
ここでの本番は「次にAIへ出す指示」です。評価軸は1つだけ見て、弱点・指示の穴・改善例を返します。
テストに落ちていてもレビューできます。落ちた理由と、指示に足りなかった情報を結びつけます。