QOJ.ac

QOJ

Time Limit: 2 s Memory Limit: 1024 MB

#23933. Hamming Distance

Statistics

問題文

整数 N と,2 つの長さ N の 文字列 S, T が与えられる.S と T のハミング距離を出力せよ.

ここで S と T のハミング距離とは,S の i 文字目と T の i 文字目が異なるような i (1 ≦ i ≦ N) の個数である.

制約

  • 1 ≦ N ≦ 100.
  • N は整数である.
  • S, T は英小文字からなる長さ N の文字列である.

入力

入力は以下の形式で与えられる.
N
S
T

出力

S と T のハミング距離を出力せよ.

結果以外は何も出力しないこと.(入力を促す文章なども出力しないこと.)

解答形式については,練習問題やその解答例 を参考にしても良い.


入力例 1

3
joi
ioi

出力例 1

1
  • S と T それぞれの 1 文字目は j と i であり,異なる.
  • S と T それぞれの 2 文字目は o と o であり,一致する.
  • S と T それぞれの 3 文字目は i と i であり,一致する.
  • よって joi と ioi のハミング距離は 1 であるので,1 を出力する.

入力例 2

5
march
april

出力例 2

4
  • march と april のハミング距離は 4 であるので,4 を出力する.

入力例 3

6
sample
sample

出力例 3

0
  • sample と sample のハミング距離は 0 であるので,0 を出力する.

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.