0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

AtCodeのビギナー用A問題をひたすら解いてます。
たまーにB問題を解いて苦しんでます。。。💦

AtCoder Beginner Contest 322

image.png

なんか小難しく書いてあるけど、文字列Tの最初数文字が文字列Sと一致するか否か?
文字列Tの最後数文字が文字列Sと一致するか否か?の組み合わせですね。

n,m=map(int,input().split())
s=input()
t=input()

if t[:n]==s:    #接頭辞
    print(0) if t[-n:]==s else print(1)
else:           #接頭辞じゃない
    print(2) if t[-n:]==s else print(3)

覚えたif文を1行でまとめるを無理やり使ったけど、かえってわかりづらくなったような?

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?