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を試す (5)

前回からの続きです。 プロセス間の通信を行ってみます。 multiprocessing.Pipe() Pipe を使うことで、2つのプロセスの通信を行うことができます。 multiprocessing.Pipe() 実用的な意味は全...

記事を読む

[Python] 2分ヒープ (2)

前回からの続きです。 Python では、heapq によりheapがモジュールとして提供されているので、普段はこちらを使います。 heapq--- ヒープキューアルゴリズム ここでは、学習のため、前回の内容に沿って、Python で heap を...

記事を読む

[Python] N桁のビット列を全て求める

問題 N桁のビット列を全て求めなさい。 回答 その1 def apped_zero_one_front(x, L): return def bit_strings(n): if n == 0: return [] ...

記事を読む

[Python] トポロジカルソート

トポロジカルソートを Python で書きます。 以下の続きです。 トポロジカルソート トポロジカルソート(英:topological sort)とは、グラフ理論において、有向非巡回グラフ(英:directed acyclic graph, DA...

記事を読む

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

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

記事を読む


Public Domain YottaGin No Rights Reserved.