# B - Prefix and Suffix ## 題目連結:[B - Prefix and Suffix](https://atcoder.jp/contests/abc322/tasks/abc322_b) ## 解題想法 * 如果`t`的前面`n`項跟`s`完全一樣,那麼就是prefix * 如果`t`的後面`n`項跟`s`完全一樣,那麼就是suffix * 先判斷prefix+suffix同時發生,接著判斷只有prefix,再判斷只有suffix ## 程式碼 ```python= n,m = map(int,input().split()) s,t = input(),input() if s == t[:n] and s == t[-n:]: print(0) elif s == t[:n]: print(1) elif s == t[-n:]: print(2) else: print(3) ```