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] 素集合データ構造

Python で素集合データ構造を実装します。 素集合データ構造 wikipedia を見てみます。 素集合データ構造(そしゅうごうデータこうぞう、英: disjoint-set data structure)は、データの集合を素集合(互いにオーバーラップしな...

記事を読む

[Python] 2分探索 リストの中でindexと数値が等しいもの

2分探索 2分探索の練習をします。 重複のないリストの中で、indexの値と数値が等しいものを探します。 例えば、というリストであれば3、というリストであれば0、というリストであればNoneが答えになります。 def find_value_e...

記事を読む

[Python] Educational DP Contest E – Knapsack 2

問題 E - Knapsack 2 回答 TLEで間に合わない最初の回答 アルゴリズム的には合っているかな? import sys # input処理を高速化する input = sys.stdin.readline # 入力 N, W = ...

記事を読む

[Python] ABC004 C

C - 入れ替え n = int(input()) n = n % 30 lst_num = for i in range(n): first = i % 5 + 1 second = i % 5 +2 lst_num, lst_num =...

記事を読む

[Python] ABC016 C

問題 C - 友達の友達 回答 友達の友達を数える 集合を使い、友達の友達を探索して数えます。 import collections N, M = map(int, input().split()) adjacent_dict = col...

記事を読む


Public Domain YottaGin No Rights Reserved.