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] 0…k-1からN桁の数列を作成

問題 0...k-1から作ることのできる長さnの数字の列を全て求めなさい。 回答 def range_to_list(k): result = [] for i in range(k): result.append(str(i)...

記事を読む

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

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

記事を読む

[Python] Kadane’s algorithm

最大部分配列問題 数値で構成された配列内の部分配列の中で、総和が最大となるものを求めます。 Incomputer science, themaximum sum subarray problemis the task of finding a contig...

記事を読む

[Python] ロジスティック回帰での株価予測

ロジスティック回帰で、翌日の株価の上昇/下降を予測します。 ロジスティック回帰 ロジスティック回帰(ロジスティックかいき、英:Logistic regression)は、ベルヌーイ分布に従う変数の統計的回帰モデルの一種である。 出典: フリー百科事典『ウィ...

記事を読む


Public Domain YottaGin No Rights Reserved.