LoginSignup
0
0

More than 1 year has passed since last update.

AtCoder B - Power Socket 解説

Last updated at Posted at 2021-11-23

ソケットの数は電源タップ×数で求められる。
また、ソケットはタップを1つ使うごとに1つ消費される。
ソケット数がbを上回った時のタップの数が答えになる。

上記を理解したがコードに落としこめず。

a,b=map(int,input().split())
for i in range(20): # iを電源タップの数とする
    socket=i*a-(i-1) # 未使用の差込口=電源タップの数×A個口の電源タップ1つ-(電源タップの数-1)
    if socket>=b: # 電源タップの数が未使用の差込口Bの値を超えたとき
        print(i) 
        break

参考
https://atcoder.jp/contests/abc139/submissions/27460318

競プロ系の記事はgithubに移行予定。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0