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

問題 B - トリボナッチ数列 参考 GeeksForGeeks Tribonacci Numbers 英語のサイトですが、トリボナッチ数列の普通の解き方->効率的な解き方のコードが一通りの言語で載っています。 回答 動的計画法 imp...

記事を読む

[Python] pandasで特定文字が出現するごとにデータフレームを分割

何度かググっているので、自分用にメモをしておきます。 pandasで、ある特定の文字、例えば"sep"が行に出てきたら、その次の行からまた"sep"が出てくるまでを、別のデータフレームとして分割したいときは、下記のようにする。 df.groupby((df == ...

記事を読む

[Python] ABC016 B

問題 B - A±B Problem 回答 A, B, C = map(int, input().split()) sum_ab = A + B diff_ab = A - B if sum_ab == C and diff_ab == C: ...

記事を読む

[Python] ABC012 A

問題 A - スワップ 回答 A, B = map(int, input().split()) tmp = A A = B B = tmp print(A, B) Python では、変数の入れ替えを一度に行うこともできます。 これは、Pyth...

記事を読む

[Pyhon] AVL木

以下を参照しています。 AVL Tree | Set 1 (Insertion) AVL Tree | Set 2 (Deletion) また、ざっくりとした説明は、以下の動画が一番分かりやすかったです。 インドの人は説明が上手です。 ...

記事を読む


Public Domain YottaGin No Rights Reserved.