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] Stackを実装

Stack スタックは、コンピュータで用いられる基本的なデータ構造の1つで、データを後入れ先出し(LIFO: Last In First Out; FILO: First In Last Out)の構造で保持するものである。抽象データ型としてのそれを指すこともあれば、そ...

記事を読む

[Python] ABC009 C

問題 C - 辞書式順序ふたたび ヒントと解説 (p.32-) が分かりやすいです。 「同じ長さの文字列s, t が与えられたとき、t を並び替えて、s との不一致の数を最小とする」ことを考えるには、結局、「それぞれの文字の数の差」を考えるだけで良い。 ...

記事を読む

[Python] ABC015 D メモ化再帰 100点

問題 D – 高橋くんの苦悩 回答 defaultdict defaultdict を使ってみましたが、残念ながらTLEでした。 import collections W = int(input()) N, K = map(int, ...

記事を読む

[Python] ABC004 D 動的計画法

問題 D - マーブル 動的計画法を使って解く。 回答 動的計画法 参考 はやくプロになりたい ABC 004 Hacking to the Gate ! 別館 AtCoder Beginer Contest 004 - D ...

記事を読む

[Python] 数値と数字の変換

数字→数値 組み込み関数intを使います。 組み込み関数intを使わないで書いてみます。 def str_to_int(str_num): # 正と負で変換の開始位置が異なる。 if str_num == '-': s...

記事を読む


Public Domain YottaGin No Rights Reserved.