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] k近傍法 (1)

scikit-learn という有名なモジュールを用いて、有名なあやめの分類問題を、k近傍法で解いてみます。 IPython で行います。 k近傍法 k近傍法(ケイきんぼうほう、英:k-nearest neighbor algorithm,k-NN)は、特徴空...

記事を読む

[グラフ ] クラスカル法をPythonで実装

Python でクラスカル法を実装します。 SciPy で最小全域木を求める時はクラスカル法を使っています。 scipy.sparse.csgraph.minimum_spanning_tree Vertex と Edge 与えられた...

記事を読む

[Python] コマンドプロンプトでtermcolorが文字化けする時

windows10のコマンドプロンプトでpythonのtermcolorで出力に色をつけようとすると、色ではなく文字化けが発生します。 termcolor は unix で使われる ANSIエスケープシーケンスというものを使うためで、これが windows のコマンドプ...

記事を読む

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

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

記事を読む

[Python] multiprocessingを試す (1)

multiprocessing multiprocessing とは、プロセスベースで並列処理を行う python の bulid-in モジュールです。 処理を並列に行えるので、処理が速くなります。 multiprocessing--- プロセスベースの並列...

記事を読む


Public Domain YottaGin No Rights Reserved.