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] ABC003 B

B - AtCoderトランプ s = input() t = input() commercial_at = flag = True for i in range(len(s)): if s == t: continue elif ...

記事を読む

[Python] multiprocessingを試す (4)

前回からの続きです。 pool python で mulitprocessing を行う方法として、process 以外に pool があります。 プロセスプール process と pool の違い Python Multiproce...

記事を読む

[Python] bit演算で偶数奇数の判断

普通は「%」を使って偶奇の判断を行うと思いますが、ここではbit演算の「and」で数字の偶奇の判断を行ってみます。 ビット単位演算 ビット演算(ビットえんざん、bitwise operation: 直訳すると「ビット毎操作」)とは、固定長のワードなどといった「ビッ...

記事を読む

[Python] ラビン-カープ法

ラビン-カープ法 テキストの中からパターンを探すときに、パターンのハッシュと検索箇所のハッシュが一致するかどうかを比較して検索を行います。 ハッシュの時間計算量が \(O(m)\) の場合は、アルゴリズム全体の計算量が \(O(m \times n) \) ...

記事を読む

[Python] 文字列のブルートフォース探索

与えられた文字列の中から、パターンに一致する部分を総当たりで探します。 時間計算量は \( O(n \times m) \)、空間計算量は\( O(1) \) になります。 import random import string def match_pa...

記事を読む


Public Domain YottaGin No Rights Reserved.