vku_spring_code_r2_ltpq
Used binary representation and bitwise operatorsunknown
python
3 years ago
583 B
15
Indexable
class ChallengeClass:
def Verify(_, s):
s = list(map(int, s.split(', ')))
def X(i):
R = s[i] <= 50
if i > 4:
R = s[i] in map(lambda x : sum(map(lambda j : (x>>j&1) * s[i-1-j], range(5))) if x.bit_count()>1 else -1, range(32))
if i: R &= X(i-1)
return R
return X(len(s)-1)
print(
# ChallengeClass().Verify("1, 2, 3, 4, 5, 16")
ChallengeClass().Verify("15, 17, 1, 38, 19, 70, 75, 58, 89, 203, 234, 659, 350, 1535, 437, 2428, 1885, 6635, 4400, 15785")
)
Editor is loading...