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

問題 B - 高橋くんと文字列圧縮 回答 s = input() s_compressed = '' cnt = 1 for i, ch in enumerate(s): if i == 0: ch_pre = ch ...

記事を読む

[Python] ABC013 B

問題 B - 錠 回答 前方向と後ろ方向に全探索します。 a = int(input()) b = int(input()) def next_digit(num): if num == 9: return 0 else...

記事を読む

[Python] Punctuationの一括削除

punctuationとは、記号文字列のことです。 str.translate() を使う方法と、正規表現を使う方法で行ってみます。 str.translate() を使うPunctuationの削除 str.translate()を使い、Punctuat...

記事を読む

[Python] Educational DP Contest G – Longest Path

問題 G - Longest Path 有向非巡回グラフであり、DP の更新順序が非自明な問題です。 メモ化再帰を使うか、トポロジカルソートを使います。 解き方は以下を参考にしています。 Educational DP Contest の F ~ J...

記事を読む

[Python] 壁伸ばし法による迷路生成

迷路生成のアルゴリズム 迷路生成のアルゴリズムは数多くあります。 Maze Classification -Maze Creation Algorithms 迷路生成の各種アルゴリズムのC++実装 (Win/Mac両対応) 棒倒し法、穴掘り法と迷路作成の...

記事を読む


Public Domain YottaGin No Rights Reserved.