AtCoder Beginners Contest 083[A to C]

Tasks

 

A. Libra … Basic if…else structure

a,b,c,d = list(map(int, input().split()))

if a+b > c+d:
    print('Left')
elif a+b == c+d:
    print('Balanced')
else:
    print('Right')

 

B. Some Sums … I used brute force as the expected N is up to 10^4. So I just iterate all the numbers from 1 to N.

a,b,c,d = list(map(int, input().split()))

if a+b > c+d:
    print('Left')
elif a+b == c+d:
    print('Balanced')
else:
    print('Right')

 

C. Multiple Gift … I used kind of brute force here as well. Multiply current number by 2, 3, 4… and check if modulus is 0 each time.

x, y = list(map(int, input().split()))

count = 1
curr_num, next_num = x, x*2
multiplier = 2
while next_num <= y:
    if next_num%curr_num == 0:
        count += 1
        multiplier = 2
        curr_num = next_num
    else:
        multiplier += 1
    next_num = curr_num * multiplier

print(count)