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] 配列内で同じ整数を探す

正の整数の配列の中に、同じ整数があるかどうか探します。 ただし、整数の最大値は、配列のサイズより小さいものとします。 総当たり 総当たりで同じ整数があるか探します。 時間計算量は\( O(N^2) \) になります。 def find_du...

記事を読む

[Python] 穴掘り法による迷路生成

迷路生成のアルゴリズム 迷路生成のアルゴリズムは数多くあります。 Maze Classification -Maze Creation Algorithms 迷路生成の各種アルゴリズムのC++実装 (Win/Mac両対応) 前回は棒倒し法を用いて迷路を作...

記事を読む

[Python] ABC016 C

問題 C - 友達の友達 回答 友達の友達を数える 集合を使い、友達の友達を探索して数えます。 import collections N, M = map(int, input().split()) adjacent_dict = col...

記事を読む

[Python] ABC001 B

B - 視程の通報 m = int(input()) if m < 100: vv = 0 elif m>=100 and m<=5000: vv = m//100 elif m>=6000 and m<=30000: vv =...

記事を読む

[Python] Punctuationの一括削除

punctuationとは、記号文字列のことです。 str.translate() を使う方法と、正規表現を使う方法で行ってみます。 str.translate() を使うPunctuationの削除 str.translate()を使い、Punctuat...

記事を読む


Public Domain YottaGin No Rights Reserved.