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] ABC008 C

問題 C - コイン 解説を読めば理解はできるけど、自分は思いつけるようになるのだろうか? 順列 99点回答 コインの順列に対して全探索を行います。 Pythonでは、itertools.permutations(iterable,r=No...

記事を読む

[Python] Educational DP Contest L – Deque

問題 L - Deque 参考 例題 3.EDPC L 問題 - Deque 〜 得点差も最大化したい 〜 Deque 回答 DP PyPyではAC。 import sys # input処理を高速化する input = sys...

記事を読む

[Python] 2分探索 平方根以下の最大の整数

2分探索 2分探索の練習をします。 2分探索を使って、ある自然数の平方根以下で最大となる整数を求めてます。 例えば、500であれば\( \sqrt 500 = 22.360679774...\)で、求めたい数字は22になります。 de...

記事を読む

[Python] ABC015 D メモ化再帰 100点

問題 D – 高橋くんの苦悩 回答 defaultdict defaultdict を使ってみましたが、残念ながらTLEでした。 import collections W = int(input()) N, K = map(int, ...

記事を読む

[Python] 壁伸ばし法による迷路生成

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

記事を読む


Public Domain YottaGin No Rights Reserved.