This blog contains all of my solutions to the mock contest of BDAIO. Why did I post this? Because I felt like doing it even tho these questions are way too easy to solve
This thingy is for beginners, didn’t include explanations because too easy to put in
A. Fibonacci Numbers[solution]
def fibonacci(n):
if n == 1 or n == 2:
return 1
a, b = 1, 1
for _ in range(3, n + 1):
a, b = b, a + b
return b
N = int(input())
print(fibonacci(N))
B. Divisors[solution]
n = int(input())
def divisor(n):
for i in range(1,n+1):
if n%i == 0:
print(i)
divisor(n)
C. Match Sticks[solution]
import sys
def yes_or_no(n):
n_fin = n - 2
if n > 4 and n_fin % 3 == 0:
print("Yes")
else:
print("No")
for line in sys.stdin:
n = int(line.strip())
yes_or_no(n)
D. Passwords[solution]
import sys
def how_many_pass(s):
check_lower = 0
check_upper = 0
check_digit = 0
pass_count = 0
for char in s:
if char.islower():
check_lower = 1
elif char.isupper():
check_upper = 1
elif char.isdigit():
check_digit = 1
if check_lower + check_upper + check_digit == 3:
pass_count += 1
check_lower = check_upper = check_digit = 0
print(pass_count)
for line in sys.stdin:
s = line.strip()
how_many_pass(s)
E. Byang’s Day Out[solution]
import sys
def yes_or_no(a, b, c):
if a + b >= c and a + c >= b and b + c >= a:
return "Yes"
else:
return "No"
input_lines = sys.stdin.read().splitlines()
t = int(input_lines[0])
for i in range(1, t + 1):
a, b, c = map(int, input_lines[i].split())
print(yes_or_no(a, b, c))
Leave a Reply to Participant Cancel reply