QOJ.ac

QOJ

حد الوقت: 2 s حد الذاكرة: 1024 MB

#23933. ระยะทางแฮมมิง

الإحصائيات

โจทย์ปัญหา

กำหนดจำนวนเต็ม $N$ และสตริง $2$ ตัวที่มีความยาว $N$ คือ $S, T$ จงแสดงระยะทางแฮมมิงระหว่าง $S$ และ $T$

ในที่นี้ ระยะทางแฮมมิงระหว่าง $S$ และ $T$ คือจำนวนของ $i$ ($1 \le i \le N$) ที่อักขระตัวที่ $i$ ของ $S$ และอักขระตัวที่ $i$ ของ $T$ แตกต่างกัน

ข้อจำกัด

  • $1 \le N \le 100$
  • $N$ เป็นจำนวนเต็ม
  • $S, T$ เป็นสตริงความยาว $N$ ที่ประกอบด้วยตัวอักษรภาษาอังกฤษพิมพ์เล็ก

ข้อมูลนำเข้า

ข้อมูลนำเข้าจะกำหนดให้ในรูปแบบต่อไปนี้:

N
S
T

ข้อมูลส่งออก

จงแสดงระยะทางแฮมมิงระหว่าง $S$ และ $T$

ห้ามแสดงสิ่งอื่นใดนอกจากผลลัพธ์ (ห้ามแสดงข้อความแจ้งให้ป้อนข้อมูล ฯลฯ)

สำหรับรูปแบบคำตอบ สามารถดูอ้างอิงได้จากโจทย์ฝึกหัดและตัวอย่างคำตอบ

ตัวอย่างที่ 1

ตัวอย่างข้อมูลนำเข้า 1

3
joi
ioi

ตัวอย่างข้อมูลส่งออก 1

1
  • อักขระตัวที่ $1$ ของ $S$ และ $T$ คือ j และ i ตามลำดับ ซึ่งแตกต่างกัน
  • อักขระตัวที่ $2$ ของ $S$ และ $T$ คือ o และ o ตามลำดับ ซึ่งตรงกัน
  • อักขระตัวที่ $3$ ของ $S$ และ $T$ คือ 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.