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] ABC011 A

問題 A - 来月は何月? 回答 N = int(input()) # 12月以外 if N < 12: print(N+1) # 12月 else: print(1) 実際に Python で翌月や翌年といった計算を行う時は、d...

記事を読む

[Python] ABC002 D by python

D - 派閥 from itertools import combinations n, m = map(int, input().split()) matrix_relations = * n for _ in range(n)] # matrixに関係を格納する。...

記事を読む

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

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

記事を読む

[Python] 算術式の2分木表現/ Expression Tree

算術式の2分木表現 2分木を用いることで、式を表現することができます。 図の例では、二項演算子を用いた算術式を二分木で表現している。この式を逆ポーランド記法、中置記法、ポーランド記法で記述すると、それぞれa b + c d - ×e f + ÷(a + b...

記事を読む

[Python] multiprocessingを試す (1)

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

記事を読む


Public Domain YottaGin No Rights Reserved.