私の記録ブログ

趣味の記録

atcoder abc_120 を解いてみた(python3)

-A. [AC]Favorite Sound

# -*- coding: utf-8 -*-

a, b, c  = map(int,input().split())

if b//a >= c:
    print(c)
else:
    print(b//a)

b/a で計算結果、b%a で余り、b//a で商を取得。

-B. [AC]K-th Common Divisor

# -*- coding: utf-8 -*-

a, b, k  = map(int,input().split())

lst = []
for i in range(1,101):
    if a%i == 0 and b%i == 0:
        lst.append(i)

print(lst[-k])

range(1,101) は、i に 1~100 まで代入する。
公約数リストを作成して、append で余り0のとき追加。
lst[-k]で、後ろからk番目を出力。

-C. Unification

-D. Decayed Bridges

今回のコンテスト後のレート
f:id:naolllab:20190309163758j:plain