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] コマンドプロンプトでtermcolorが文字化けする時

windows10のコマンドプロンプトでpythonのtermcolorで出力に色をつけようとすると、色ではなく文字化けが発生します。 termcolor は unix で使われる ANSIエスケープシーケンスというものを使うためで、これが windows のコマンドプ...

記事を読む

[Python] 配列内で同じ整数を探す

正の整数の配列の中に、同じ整数があるかどうか探します。 ただし、整数の最大値は、配列のサイズより小さいものとします。 総当たり 総当たりで同じ整数があるか探します。 時間計算量は\( O(N^2) \) になります。 def find_du...

記事を読む

[Python] ABC013 B

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

記事を読む

[Python] ABC006 A

問題 A - 世界のFizzBuzz 回答 import sys # input処理を高速化する input = sys.stdin.readline def main(): N = int(input()) if N % 3 == 0: ...

記事を読む

[Python] bit演算でn番目のbitを0にする

以下の記事の続きです。 今回は、bit演算でn番目のbitを0にします。 簡略化のため、n番目は0から始まると考えます。 ビットの反転 演算子~ は、0と1を逆にする、つまりビットを反転する演算子です。 >>> ~0 -1 >>...

記事を読む


Public Domain YottaGin No Rights Reserved.