AtCoder Beginner Contest 148 過去問 (A~C)

参照

atcoder.jp

A問題

特に問題なく

a=int(input())
b=int(input())
print(6-a-b)

B問題

特に問題なく

n=int(input())
s,t=input().split()
str_=''
for i in range(n):
  str_+=(s[i]+t[i])
print(str_)

C問題

aとbの最小公倍数を求める問題。
1≤N≤10^5でしたので、1重ループは可能です。
最小公倍数はaとbの大きい方の数の倍数であることに
間違い無いので、その倍数を調べていきました。

ab=list(map(int,input().split()))
i=max(ab)
while True:
  if i%ab[0]==0 and i%ab[1]==0:
    print(i)
    break
  i+=max(ab)