YottaGin

Freedom is a responsible choice.

[Python] ABC014 A

2019/12/6 2019/12/6 プログラミング

問題

A – けんしょう先生のお菓子配り

回答

a = int(input())
b = int(input())

remainder = a % b

shortage = 0
if remainder > 0:
    shortage = b - remainder

print(shortage)

Atcoder, Python GinO

関連記事

[Python] 数値と数字の変換

数字→数値 組み込み関数intを使います。 組み込み関数intを使わないで書いてみます。 def str_to_int(str_num): # 正と負で変換の開始位置が異なる。 if str_num == '-': s...

記事を読む

[Python] ABC016 B

問題 B - A±B Problem 回答 A, B, C = map(int, input().split()) sum_ab = A + B diff_ab = A - B if sum_ab == C and diff_ab == C: ...

記事を読む

[Python] Educational DP Contest I – Coins

問題 I - Coins 確率DPの問題。 参考資料 確率 DP を極めよう 回答 TLEだった回答 PyPyではAC。 import sys # input処理を高速化する input = sys.stdin.readli...

記事を読む

[Python] requests/beautifulsoup でスクレイピング

requests/beautifulsoup/lxml のコンビでスクレイピングを行ってみます。 Requests Requests: HTTP for Humans™ Python で一番使いやすいHTMLライブライです。 下記コマンドで...

記事を読む

[Python] ABC011 B

問題 B - 名前の確認 回答 S = input() ans = S.capitalize() print(ans) str.capitalize() というメソッドで、先頭の文字のみ大文字に変換できます。 組み込み関数のみで書く 解説...

記事を読む


Public Domain YottaGin No Rights Reserved.