mukul02's blog

By mukul02, history, 4 years ago, In English

Python Solution

1419A - Цифробой

t = int(input())

while t > 0:
    n = int(input())
    s = input()
    if s[n-1] == '0':
        s.replace(s[n-1],'') 
    odd,even = False, False
    i = 1
    for i in range(n+1):
        if i % 2 == 1:
            odd |= (int(s[i - 1]) % 2 == 1)
        else:
            even |= (int(s[i - 1]) % 2 == 0)
    
    if n % 2 == 1:
        if (odd):
            print(1)
        else:
            print(2)
    else:
        if (even):
            print(2)
        else:
            print(1)
    t -= 1

  • Vote: I like it
  • -12
  • Vote: I do not like it

| Write comment?