본문 바로가기

코딩테스트/프로그래밍 기초 | 조건문

[코드트리] if if 조건문

최대 2번의 연산

https://www.codetree.ai/missions/4/problems/up-to-2-calculations?&utm_source=clipboard&utm_medium=text

a = int(input())

if a % 2 == 0:
    a = a//2

if a % 2 != 0:
    a = (a+1)//2

print(a)

 

 

 

 

숫자의 조건 여부 2

https://www.codetree.ai/missions/4/problems/number's-condition-2?&utm_source=clipboard&utm_medium=text

a = int(input())

if a == 5:
    print("A")

if a % 2 == 0:
    print("B")

 

 

 

 

두 번의 연산

https://www.codetree.ai/missions/4/problems/two-operations?&utm_source=clipboard&utm_medium=text

a = int(input())

if a % 2 != 0:
    a = a + 3

if a % 3 == 0:
    a = a // 3

print(a)