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] 決定性有限オートマトンを使った文字列検索

以下の続きです。 下の動画を参考にしています。 決定性有限オートマトンを使うと、文字列検索アルゴリズムは以下の流れで表現できます。 オートマトンを作る あるパターン\( P \)が与えられたとして、そのパターンに...

記事を読む

[Python] ABC012 B

問題 B - 入浴時間 回答 N = int(input()) seconds = N % 60 minutes = (N // 60) % 60 hours = N // (60 ** 2) % 60 s_seconds = '{:02d}'.forma...

記事を読む

[Python] Kadane’s algorithm

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

記事を読む

[Python] ABC014 C いもす法

問題 C - AtColor 回答 いもす法を使います。 いもす法 改札にチケットを何枚入れれば良いのかを、いもす法で解いてみた 累積和は itertools の accumulate を使います。 itertools.accum...

記事を読む

[Python] ABC017 D しゃくとり法

問題 D – サプリメント 回答 ちょっと手も足も出なかった感じ。 30点回答 そもそも dp の配列をどう作るのかすら分からなかった。 スライドや解説動画をじっくり眺めます。 AtCoder Beginner Contest...

記事を読む


Public Domain YottaGin No Rights Reserved.