QOJ.ac

QOJ

Límite de tiempo: 2 s Límite de memoria: 1024 MB

#23933. 漢明距離

Estadísticas

題目描述

給定一個整數 $N$ 以及 $2$ 個長度為 $N$ 的字串 $S, T$。請輸出 $S$ 與 $T$ 的漢明距離。

在此,$S$ 與 $T$ 的漢明距離是指滿足 $S$ 的第 $i$ 個字元與 $T$ 的第 $i$ 個字元相異的 $i$($1 \le i \le N$)之個數。

資料範圍

  • $1 \le N \le 100$。
  • $N$ 為整數。
  • $S, T$ 為由英文小寫字母組成、長度為 $N$ 的字串。

輸入格式

輸入以以下格式給出:

N
S
T

輸出格式

請輸出 $S$ 與 $T$ 的漢明距離。

請勿輸出結果以外的任何內容。(也請勿輸出提示輸入的文字等。)

關於作答格式,也可以參考練習題及其解答範例。

範例 1

範例輸入 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

範例輸入 2

5
march
april

範例輸出 2

4
  • 因為 march 與 april 的漢明距離為 $4$,故輸出 $4$。

範例 3

範例輸入 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.