A. Collatz Algorithm
Solution
def read():
return int(input())
def read_list():
return [int(i) for i in input().split()]
n = read()
print(n, end=' ')
while n != 1:
if n % 2 == 0:
n //= 2
else:
n *= 3
n += 1
print(n, end=' ')
B. DNA Counting
Solution
def read():
return int(input())
def read_list():
return [int(i) for i in input().split()]
s = input()
count = {}
a = "ACGT"
for c in a:
count[c] = 0
for c in s:
count[c] += 1
for c in a:
print(count[c], end=' ')
C. TPCP 2023 – Is it a Helal Sequence?
Solution
def read():
return int(input())
def read_list():
return [int(i) for i in input().split()]
n, x = read_list()
a = read_list()
result = 1
for i in a:
result *= i
result %= x
if result == 0:
print("yes")
else:
print("no")
Auto comment: topic has been updated by ammar007 (previous revision, new revision, compare).