0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

AtCoder Beginner Contest 157A - Duplex Printingメモ(python)

Posted at

ABC157Aを解いて間違えたのでメモします。以下常体。

問題

AtCoder Beginner Contest 157A - Duplex Printing

考察

答えは与えられたn2割り切り上げた数。
そのために、与えられたnをなんらかの数字を足して2で割り切れる数、つまり2の倍数にすることを考える。
奇数を2にの倍数にするには+1すればよい。つまり、2で割った切り上げはn+1で求められる。また、pythonの//演算子は切り捨てなので偶数を+1して//2の操作をしても偶数をそのまま//2の操作をしたことと結果は変わらない。

ACコード

def printer(n):
    return (n+1)//2 
n=int(input())

print(printer(n))
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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?