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

問題 B - 錠 回答 前方向と後ろ方向に全探索します。 a = int(input()) b = int(input()) def next_digit(num): if num == 9: return 0 else...

記事を読む

[Python] multiprocessingを試す (4)

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

記事を読む

[Python] pandasでUnicodeDecodeErrorが起きた時

Windowsで作成したcsvファイルをpandasで開こうとすると、良くUnicodeDecodeErrorが出ていらいらさせられます。 read_csvでencoding='cp932'つけることで今までは解決していたのですが、なぜか今回はうまくいきません。 ...

記事を読む

[Python] 配列を逆順にする

与えられた配列を逆順にする In-place アルゴリズムを Python で書いてみます。 通常は list.reverse() や list を使います。 考え方は簡単で、左右両端にインデックスを置いて入れ替え、その後一つ狭めてさらに左右両端を入れ替える…と...

記事を読む

[データ構造] AVL木を Python で実装

Python でAVL木を実装します。 ノード 2分探索木とあまり変わりません。 height というインスタンス変数を設定し、ノードの高さを保持します。 class Node(object): def __init__(s...

記事を読む


Public Domain YottaGin No Rights Reserved.