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] multiprocessingを試す (2)

以下の記事の続きです。 Python の multiprocessing で lock を使ってみます。 multiprocessing の際にリソースを共有した場合、lock をしておかないと変なことになるという話です。 lock lock...

記事を読む

[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] 通路を見つける

問題 N×Nの行列があり、左端上から右端下までの通路を探す。道は1壁は0で表される。また、右が下の方向にのみ進むことができる。 例 下の行列であれば、(0, 0) -> (0, 1) -> (1, 1) -> (1, 2) -> (2, 2) -> (...

記事を読む

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

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

記事を読む

[Python] Educational DP Contest A – Frog 1

ABC004 Dを動的計画法で解きたい -> 動的計画法って何? -> accoderに動的計画法のコンテストがある! という順番です。 DPとはDynamic Programming、動的計画法の略です。 動的計画法(どうてきけいかくほう、英:...

記事を読む


Public Domain YottaGin No Rights Reserved.