Problem:


Score : 400 points

Problem Statement

There are N empty boxes arranged in a row from left to right.
The integer i is written on the i-th box from the left (1 \leq i \leq N).

For each of these boxes, Snuke can choose either to put a ball in it or to put nothing in it.

We say a set of choices to put a ball or not in the boxes is good when the following condition is satisfied:

For every integer i between 1 and N (inclusive), the total number of balls contained in the boxes with multiples of i written on them is congruent to a_i modulo 2.

Does there exist a good set of choices? If the answer is yes, find one good set of choices.

Constraints

All values in input are integers.

1 \leq N \leq 2 \times 10^5

a_i is 0 or 1.

Input

Input is given from Standard Input in the following format:

N
a_1 a_2 ... a_N

Output

If a good set of choices does not exist, print -1.

If a good set of choices exists, print one such set of choices in the following format:

M
b_1 b_2 ... b_M

where M denotes the number of boxes that will contain a ball, and b_1,\ b_2,\ ...,\ b_M are the integers written on these boxes, in any order.

Sample Input 1

3
1 0 0

Sample Output 1

1
1

Consider putting a ball only in the box with 1 written on it.

There are three boxes with multiples of 1 written on them: the boxes with 1, 2, and 3. The total number of balls contained in these boxes is 1.

There is only one box with a multiple of 2 written on it: the box with 2. The total number of balls contained in these boxes is 0.

There is only one box with a multiple of 3 written on it: the box with 3. The total number of balls contained in these boxes is 0.

Thus, the condition is satisfied, so this set of choices is good.

Sample Input 2

5
0 0 0 0 0

Sample Output 2

0

Putting nothing in the boxes can be a good set of choices.



Sample input:
3
1 0 0


Sample output:
1
1

Submission status: Wrong Answer

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def main():
    N = int(readline())
    b = [0]+[int(i) for i in readline().split()]
    table = [0 for _ in range(N+1)]     
    def S(a, i):
        res = 0
        while i <= N:
            res += a[i]
            i+=i
        return res%2
    for i in reversed(range(1, N+1)):
        table[i] = (S(table, i)+b[i])%2
    m = sum(table)
    print(m)
    for i in range(1, N+1):
        if table[i]:
            print(i, end=' ')
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def main():
    N = int(readline())
    b = [0]+[int(i) for i in readline().split()]
    table = [0 for _ in range(N+1)]     
    def S(i):
        res = 0
        while i <= N:
            res += table[i]
            i+=i
        return res%2
    for i in reversed(range(1, N+1)):
        table[i] = (S(i)+b[i])%2
    m = sum(table)
    print(m)
    for i in range(1, N+1):
        x = table[i]
        if x:
            print(i)
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def main():
    N = int(readline())
    b = [0]+[int(i) for i in readline().split()]
    table = [0 for _ in range(N+1)]     
    def S(i):
        res = 0
        while i <= N:
            res += table[i]
            i+=i
        return res%2
    for i in reversed(range(1, N+1)):
        table[i] = (S(i)+b[i])%2
    m = sum(table)
    print(m)
    for i in range(1, N+1):
        x = table[i]
        if x:
            print(x)
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [0]+list(map(int, input().split()))
boxi=[0]*(n+1)
box=[]
for i in range(n,0,-1):
  t=0
  for j in range(2,n//i):
    if boxi[j*i] == 1:
      t+=1
  if t%2 != a[i]:
    box.append(i)
    boxi[i]=1
else:
  print(len(box))
  box=[str(i) for i in box]
  print(" ".join(box))
#print(-1)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [0]+list(map(int, input().split()))
boxi=[0]*(n+1)
box=[]
for i in range(n,0,-1):
  t=0
  for j in range(2,n//i):
    if boxi[j] == 1:
      t+=1
  if t%2 != a[i]:
    box.append(i)
    boxi[i]=1
else:
  print(len(box))
  box=[str(i) for i in box]
  print(" ".join(box))
#print(-1)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
ans = [0] * n
for i in range(n - 1, -1, -1):
    if i + 1 > n // 2:
        ans[i] = a[i]
    else:
        cnt = 0
        for j in range(i, n, i + 1):
            if ans[j] == 1:
                cnt += 1
        #ans[i] = cnt % 2 + a[i]
        if cnt % 2 == a[i]:
            ans[i] = 0
        else:
            ans[i] = 1 
            
s = sum(ans)
print(s)
print(*[1] * s)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
s = [0] * n
for i in range(n - 1, -1, -1):
    if i + 1 >= n // 2:
        s[i] = a[i]
    else:
        cnt = 0
        for j in range(i, n, i + 1):
            if s[j] == 1:
                cnt += 1
        if cnt % 2 == a[i]:
            s[i] = 0
        else:
            s[i] = 1
print(sum(s))
for i, j in enumerate(s):
    if j == 1:
        print(i + 1)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
s = [0] * n
for i in range(n - 1, -1, -1):
    if i + 1 >= n // 2:
        s[i] = a[i]
    else:
        cnt = 0
        for j in range(i, n, i + 1):
            if a[j] == 1:
                cnt += 1
        if cnt % 2 == a[i]:
            s[i] = 0
        else:
            s[i] = 1
print(sum(s))
for i, j in enumerate(s):
    if j == 1:
        print(i + 1)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
s = [0] * n
for i in range(n - 1, 0, -1):
    if i + 1 > n // 2:
        s[i] = a[i]
    else:
        cnt = 0
        for j in range(i, n, i + 1):
            if a[j] == 1:
                cnt += 1
        if cnt % 2 == a[i]:
            s[i] = 0
        else:
            s[i] = 1
cnt1 = sum(a)
if cnt1 % 2 == 1:
    s[0] = 1
    cnt1 += 1
print(sum(s))
for i, j in enumerate(s):
    if j == 1:
        print(i + 1)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
b = [0] * n

for i in range(n, 0, -1):
    j = i
    tmp = 0
    while True:
        j += i
        if j > n:
            break
        tmp = tmp + a[j-1]
    b[i-1] = int(tmp % 2 != a[i-1])

m = sum(b)
print(m)
if m > -1:
    for i in range(n):
        if b[i]: print(i+1)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
b = [0] * n

for i in range(n, 0, -1):
    j = i
    tmp = 0
    while True:
        j += i
        if j > n:
            break
        tmp = tmp + a[j-1]
    b[i-1] = int(tmp % 2 != a[i-1])

m = sum(b)
print(m)
if m > 0:
    for i in range(n):
        if b[i]: print(i+1)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
b = [0] * n

for i in range(n, 0, -1):
    j = i
    tmp = 0
    while True:
        j += i
        if j > n:
            break
        tmp = tmp + a[j-1]
    b[i-1] = (abs(tmp - a[i-1]) % 2)

m = sum(b)
print(m)
if m > 0:
    for i in range(n):
        if b[i]: print(i+1)

Submission status: Wrong Answer

Solution code:
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

N = int(input())
A = list(map(int,input().split()))
is_ball = [-1]*(N+1)
for i in range(N,-1,-1):
  is_ball[i] = A[i-1]
  divisors = make_divisors(N)
  if A[i-1] == 1:
    for div in divisors:
      A[div-1] ^= 1
      
b=[]

for i in range(1,N+1):
  if is_ball[i] == 1:
    b.append(i)
    
print(len(b))
print(" ".join(map(str,b)))

Submission status: Wrong Answer

Solution code:
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

N = int(input())
A = list(map(int,input().split()))
is_ball = [-1]*(N+1)
for i in range(N,-1,-1):
  is_ball[i] = A[i-1]
  divisor = make_divisors(N)
  if A[i-1] == 1:
    for j in range(len(divisor)):
      A[divisor[j]-1] &= 0
b=[]

for i in range(1,N+1):
  if is_ball[i] == 1:
    b.append(i)
    
print(len(b))
print(" ".join(map(str,b)))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
ans = [0] * n
for i in  range((n + 1) // 2):
    ans[n - i - 1] == a[n - i - 1]
for i in range(n // 2):
    m = n // 2
    s = 0
    for j in range(n // (m - i) - 1):
        s += ans[(m - i) * (2 + j) - 1]
    if s % 2 != a[m - i - 1]:
        ans[m - i - 1] = 1

anss = []
for i in range(n):
    if ans[i] == 1:
        anss.append(str(i + 1))
print(len(anss))
print(' '.join(anss))

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))

i=0
b=[0]*n
while i<n:
    ii=n-i
    j=1
    temp=0
    while j*ii<=n:
        temp+=b[j*ii-1]
        j+=1
    if temp%2!=a[ii-1]:
        b[ii-1]=1
    else:
        b[ii-1]=0
    i+=1

result=[]
cnt=0
for index,item in enumerate(b):
    if item==1:
        cnt+=1
        result.append(str(index+1))
print(cnt)
if cnt>0:
    print("".join(result))

Submission status: Wrong Answer

Solution code:
import copy

N = int(input())
a = [0]+list(map(int, input().split()))
b = copy.copy(a)
for j in range(N//2, 0, -1):
    if sum(b[n*j] for n in range(2, (N//j)+1)) % 2 != a[j]:
        b[j] = 1

print(sum(b[1:]))
if sum(b[1:]) != 0:
    print(*[i for i, j in enumerate(b) if j == 1])

Submission status: Wrong Answer

Solution code:
import copy

N = int(input())
a = [0]+list(map(int, input().split()))
b = copy.copy(a)
for j in range(N//2, 0, -1):
    if sum(b[j::j]) % 2 != a[j]:
        b[j] = 1

print(sum(b[1:]))
if sum(b[1:]) != 0:
    print(*[i for i, j in enumerate(b) if j == 1])

Submission status: Wrong Answer

Solution code:
import copy

N = int(input())
a = [0]+list(map(int, input().split()))
b = copy.copy(a)
for j in range(N//2, 0, -1):
    if sum(b[n*j] for n in range(1, (N//j)+1)) % 2 != a[j]:
        b[j] = 1

print(sum(b[1:]))
if sum(b[1:]) != 0:
    print(*[i for i, j in enumerate(b) if j == 1])

Submission status: Wrong Answer

Solution code:
import copy

N = int(input())
a = [0]+list(map(int, input().split()))
b = copy.copy(a)
for j in range(N//2, 0, -1):
    if sum(b[j::j]) % 2 != a[j]:
        b[j] = 1

print(sum(b[1:]))
if sum(b[1:]) != 0:
    print(*[j for j in b if j == 1])

Submission status: Wrong Answer

Solution code:
import copy

N = int(input())
a = [0]+list(map(int, input().split()))
b = copy.copy(a)
for j in range(N//2, 0, -1):
    if sum(b[n*j] for n in range(1, (N//j)+1)) % 2 != a[j]:
        b[j] = 1

print(sum(b[1:]))
if sum(b[1:]) != 0:
    print(*[j for j in b if j == 1])

Submission status: Wrong Answer

Solution code:
import math

N = int(input())
a = [0]+list(map(int, input().split()))
b = [0 for _ in range(N+1)]
for j in range(N, 0, -1):
    if sum(b[n*j] for n in range(1, (N//j)+1)) % 2 != a[j]:
        b[j] = 1

print(sum(b[1:]))
if sum(b[1:]) != 0:
    print(*[j for j in b if j == 1])

Submission status: Wrong Answer

Solution code:
import math

N = int(input())
a = [0]+list(map(int, input().split()))
b = [0 for _ in range(N+1)]
for j in range(N, 0, -1):
    if sum(b[n*j] for n in range(2, (N//j)+1)) % 2 != a[j]:
        b[j] = 1

print(sum(b[1:]))
if sum(b[1:]) != 0:
    print(*[j for j in b if j == 1])

Submission status: Wrong Answer

Solution code:
import math

N = int(input())
a = [0]+list(map(int, input().split()))
b = [0 for _ in range(N+1)]
for j in range(N, 0, -1):
    if j > N//2:
        b[j] = a[j]
    else:
        if sum(b[n*j] for n in range(2, (N//j)+1)) % 2 == a[j]:
            b[j] = 0
        else:
            b[j] = 1

print(sum(b[1:]))
if sum(b[1:]) != 0:
    print(*[j for j in b if j == 1])

Submission status: Wrong Answer

Solution code:
import math

N = int(input())
a = [0]+list(map(int, input().split()))
b = [0 for _ in range(N+1)]
for j in range(N, 0, -1):
    if j > N//2:
        b[j] = a[j]
    else:
        if sum(b[n*j] for n in range(2, (N//j)+1)) % 2 == a[j]:
            b[j] = 0
        else:
            b[j] = 1

print(sum(b[1:]))
print(*[j for j in b if j == 1])

Submission status: Wrong Answer

Solution code:
import math

N = int(input())
a = [0]+list(map(int, input().split()))
b = [0 for _ in range(N+1)]
for j in range(2, N+1):
    for i in range((N//j)+1, N//(j-1)+1):
        b[i] = sum(a[i*k] for k in range(1,j)) % 2
b[1] = sum(a) % 2

print(sum(b[1:]))
print(*[j for j in b if j == 1])

Submission status: Wrong Answer

Solution code:
import math

N = int(input())
a = [0]+list(map(int, input().split()))
b = [0 for _ in range(N+1)]
for j in range(2, N+1):
    for i in range(N//j+1, N//(j-1)+1):
        b[i] = sum(a[i*k] for k in range(1,j)) % 2
print(sum(b[1:]))
print(*[j for j in b if j == 1])

Submission status: Wrong Answer

Solution code:
import math

N = int(input())
a = [0]+list(map(int, input().split()))
b = [0 for _ in range(N+1)]
for j in range(2, N+1):
    for i in range(math.ceil(N/j), N//(j-1)+1):
        b[i] = sum(a[i*k] for k in range(1,j)) % 2
print(sum(b[1:]))
print(*[j for j in b if j == 1])

Submission status: Wrong Answer

Solution code:
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

N = int(input())
a = list(map(int, input().split()))
b = []
multiple = [[i] for i in range(1,N+1)]
balls = [0] * N

for i in range(N,0,-1):
    if balls[i-1] % 2 != a[i-1]:
        for x in make_divisors(i):
            balls[x-1] += 1
            b.append(i)
print(len(b))
print(*b)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [0] + list(map(int,input().split()))

count = 0
B = [0]*(N+1)

for i in range(N,0,-1):
    a = A[i]
    for j in range(2,N//i):
        a += B[i*j]
    if a % 2 == 1:
        count += 1
        B[i] = 1
print(count)

for i in range(N+1):
    if B[i] == 1:
        print(i)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [0] + list(map(int,input().split()))

count = 0
B = []

for i in range(N,0,-1):
    a = A[i]
    for j in range(2,N//i):
        a += A[i*j]
    if a % 2 == 1:
        count += 1
        B.append(i)
print(count)
print(*B)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [0] + list(map(int,input().split()))

count = 0
B = []

for i in range(N,0,-1):
    a = A[i]
    for j in range(2,N//i):
        a += A[j]
    if a % 2 == 1:
        count += 1
        B.append(i)
print(count)
print(*B)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
b = [0] * n

for i in range(n, 0, -1):
    j = i
    tmp = 0
    while True:
        j += i
        if j > n:
            break
        tmp = (tmp + a[j-1]) // 2
    b[i-1] = abs(tmp - a[i-1])

m = sum(b)
print(m)
if m > 0:
    for i in range(n):
        if b[i]: print(i+1)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
b = [0] * n

for i in range(n, 0, -1):
    j = i
    tmp = 0
    while True:
        j += i
        if j > n:
            break
        tmp = (tmp + a[j-1]) // 2
    b[i-1] = (tmp + a[i-1] + 1) // 2

m = sum(b)
print(m)
if m > 0:
    for i in range(n):
        if b[i]: print(i+1)

Submission status: Wrong Answer

Solution code:
n = int(input())
li = list(map(int,input().split()))
li.reverse()
ans = [0]*n
for i,l in enumerate(li):
    j = n - i
    if n//j < 2 and l==1:
        ans[j-1] += 1
    else:
        tmp = 0
        for k in range(2,n//j+1):
            tmp += ans[j*k-1]
        if tmp%2 == 0 and l==1:
            ans[j-1] += 1
print(ans.count(1))
if ans.count(1) == 0:
    exit()
fin_li = []
for ai,a in enumerate(ans):
    if a == 1:
        fin_li.append(ai+1)
print(*fin_li)

Submission status: Wrong Answer

Solution code:
n = int(input())
li = list(map(int,input().split()))
ans = []
for i,l in enumerate(li):
    if l == 1:
        ans.append(i+1)
print(len(ans))
if len(ans)>0:
    print(*ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
a_list = list(map(int,input().split()))
dum_list = [0]*n
ans_list = []
for i in range(n-1,-1,-1):
    total = 0
    for j in range(i,n-1,i+1):
        #print(j)
        total += dum_list[j]
    if total%2 != a_list[i]:
        dum_list[i] = 1
        ans_list.append(i+1)
if sum(dum_list) == 0:
    print(0)
else:
    #print(ans_list)
    ans_list.sort()
    print(sum(dum_list))
    print(" ".join(map(str,ans_list)))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [0] + list(map(int, input().split()))
b = [0]*(n+1)
for i in range(1, n+1)[::-1]:
    if a[i] == 1:
        if sum(b[i::i]) % 2 == 0:
            b[i] = 1
        else:
            b[i] = 0
    else:
        if sum(b[i::i]) % 2 == 0:
            b[i] = 0
        else:
            b[i] = 1
print(b.count(1))
for i in range(n):
    if b[i] == 1:
        print(i)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [0] + list(map(int, input().split()))
b = [0]*(n+1)
for i in range(1, n+1)[::-1]:
    if a[i] == 1:
        if sum(b[i::i]) % 2 == 0:
            b[i] = 1
        else:
            b[i] = 0
    else:
        if sum(b[i::i]) % 2 == 1:
            b[i] = 1
        else:
            b[i] = 0
print(b.count(1))
for i in range(n):
    if b[i] == 1:
        print(i)

Submission status: Wrong Answer

Solution code:
N = int(input())
B = list(map(int, input().split()))

ans = [0]*N
for i in range(N, 0, -1):
    cnt = 0
    j = 1
    while i*j<=N:
        cnt += ans[i*j-1]
        j += 1
    if cnt%2 != B[i-1]:
        ans[i-1] = 1

if sum(ans)>= 1:
    print(sum(ans))

    A =[]
    for i, j in enumerate(ans, 1):
        if j == 1:
            A.append(i)

    print(*A)

else:
    print(-1)

Submission status: Wrong Answer

Solution code:
N = int(input())
B = list(map(int, input().split()))

ans = [0]*N
for i in range(N, 0, -1):
    print(i)
    cnt = 0
    j = 1
    while i*j<=N:
        cnt += ans[i*j-1]
        j += 1
    if cnt%2 != B[i-1]:
        ans[i-1] = 1

if sum(ans)>= 1:
    print(sum(ans))

    A =[]
    for i, j in enumerate(ans, 1):
        if j == 1:
            A.append(i)

    print(*A)

else:
    print(-1)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int, input().split()))
box = [0 for _ in range(N + 1)]
ans = []
for i in range(1, N + 1)[:: -1]:
    k = 1
    my_sum = 0
    while i * k <= N: 
        my_sum += box[i * k]
        k += 1
    if my_sum % 2 != a[i - 1]:
        box[i] = 1
        ans.append(i)
if len(ans) > 0:
    print(" ".join(map(str, ans)))
else:
    print(0)

Submission status: Wrong Answer

Solution code:
import numpy as np
N = int(input())
a = list(map(int, input().split()))
box = np.array([0 for _ in range(N + 1)])
for i in range(1, N + 1)[:: -1]:
    k = 1
    sum = 0
    while i * k <= N: 
        sum += box[i * k]
        k += 1
    if sum % 2 != a[i - 1]:
        box[i] = 1
box = box[1:]
if np.count_nonzero(box) > 0:
    ans = " ".join([str(i) for i in box[box > 0]])
else:
    ans = 0
print(ans)

Submission status: Wrong Answer

Solution code:
import math
N = int(input())
a = list(map(int, input().split()))

b = [0]*N
for i in range(N, 0, -1):
  if b[i-1] % 2 != a[i-1]:
    if i == 1:
      b[i-1] += 1
      continue
    for j in range(1, math.floor(math.sqrt(i))+1):
      if i % j == 0:
        b[j-1] += 1
        if i//j != j and i//j-1 <= N-1:
          b[i//j-1] += 1

cnt = 0
for i in range(N):
  if b[i] > 0:
    cnt += 1
print(cnt)
for i in range(N):
  if b[i] > 0:
    print(i+1, end=" ")

Submission status: Wrong Answer

Solution code:
import math
N = int(input())
a = list(map(int, input().split()))

b = [0]*N
for i in range(N, 0, -1):
  if b[i-1] % 2 != a[i-1]:
    if i == 1:
      b[i-1] += 1
      continue
    for j in range(1, math.floor(math.sqrt(i))+1):
      if i % j == 0:
        b[j-1] += 1
        if i//j != j and i//j-1 <= N-1:
          b[i//j-1] += 1

cnt = 0
for i in range(N):
  if b[i] > 0:
    cnt += 1

for i in range(N):
  if b[i] > 0:
    print(i+1, end=" ")

Submission status: Wrong Answer

Solution code:
import math
N = int(input())
a = list(map(int, input().split()))

b = [0]*N
for i in range(N, 0, -1):
  if b[i-1] % 2 != a[i-1]:
    if i == 1:
      b[i-1] += 1
      continue
    for j in range(1, math.floor(math.sqrt(i))+1):
      if i % j == 0:
        b[j-1] += 1
        if i//j != j and i//j-1 <= N-1:
          b[i//j-1] += 1

cnt = 0
for i in range(N):
  if b[i] > 0:
    cnt += 1
print(cnt)
for i in range(N):
  if b[i] > 0:
    print(i+1)

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int,input().split()))
e=0
dic={}
for i in range(N):
 d=0
 B=int(N/(N-i))
 if B==1 and A[N-i-1]==1:
   dic[N-i]=1
   e+=1
 elif B>1:
  for k in range(1,B):
   if (k+1)*B in dic:
    d+=1
  if (d+A[N-i-1])%2==1:
   dic[N-i]=1
   e+=1
if dic=={}:
 print(0)
else:
 print(e)
 b = dic.keys()
 z=[str(a) for a in b]
 z=' '.join(z)
 print(z)

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int,input().split()))
e=0
dic={}
for i in range(N):
 d=0
 B=int(N/(N-i))
 if B==1 and A[N-i-1]==1:
   dic[N-i]=1
   e+=1
 elif B>1:
  for k in range(1,B):
   if (k+1)*B in dic:
    d+=1
  if (d+A[N-i-1])%2==1:
   dic[N-i]=1
   e+=1
if dic=={}:
 print(0)
else:
 for k in dic:
  print(k)
  print(dic[k])

Submission status: Wrong Answer

Solution code:
from sys import stdin


def main():
    input = lambda: stdin.readline()[:-1]
    N = int(input())
    A = list(map(int, input().split()))

    A, b = [0] + A, [0] * (N + 1)
    n = N // 2 + 1
    b[n:] = A[n:]
    c = b[:]
    m = b.count(1)
    for i in range(n - 1, 0, -1):
        if A[i] == c[i*2] % 2:
            c[i] = c[i*2]
        else:
            b[i] = 1
            m += 1
            c[i] = c[i*2] + 1
    print(m)
    if m:
        print(*[i for i, v in enumerate(b) if v])


main()

Submission status: Wrong Answer

Solution code:
from sys import stdin


def main():
    input = lambda: stdin.readline()[:-1]
    N = int(input())
    A = list(map(int, input().split()))

    A, b = [0] + A, [0] * (N + 1)
    n = N // 2 + 1
    m = 0
    for i in range(n, N + 1):
        b[i] = A[i]
        m += A[i]
    c = b[:]
    for i in range(n - 1, 0, -1):
        if A[i] == c[i*2]:
            b[i] = 0
            c[i] = c[i*2]
        else:
            b[i] = 1
            m += 1
            c[i] = (c[i*2] + 1) % 2
    print(m)
    if m:
        print(*[i for i, v in enumerate(b) if v])


main()

Submission status: Wrong Answer

Solution code:
from sys import stdin


def main():
    input = lambda: stdin.readline()[:-1]
    N = int(input())
    A = list(map(int, input().split()))

    A, b = [0] + A, [0] * (N + 1)
    n = N // 2 + 1
    m = 0
    for i in range(n, N + 1):
        b[i] = A[i]
        m += A[i]
    c = b[:]
    for i in range(n - 1, 0, -1):
        if A[i] == c[i*2]:
            b[i] = 0
            c[i] = c[i*2]
        else:
            b[i] = 1
            m += 1
            c[i] = (c[i*2] + 1) % 2
    print(m)
    if m:
        print(*[i for i in b if i])


main()

Submission status: Wrong Answer

Solution code:
from sys import stdin


def main():
    input = lambda: stdin.readline()[:-1]
    N = int(input())
    A = list(map(int, input().split()))

    A = [0] + A
    b = [0] * (N + 1)
    n = N // 2 + 1
    m = 0
    for i in range(n, N + 1):
        b[i] = A[i]
        m += A[i]
    for i in range(n - 1, 0, -1):
        if A[i] == b[i*2]:
            b[i] = 0
        else:
            b[i] = 1
            m += 1
    print(m)
    if m:
        print(*[i for i in b if i])


main()

Submission status: Wrong Answer

Solution code:
from sys import stdin


def main():
    input = lambda: stdin.readline()[:-1]
    N = int(input())
    A = list(map(int, input().split()))

    A = [0] + A
    b = [0] * (N + 1)
    n = N // 2 + 1
    m = 0
    for i in range(n, N + 1):
        b[i] = A[i]
        m += A[i]
    for i in range(n - 1, 0, -1):
        if A[i] == b[i*2]:
            b[i] = 0
        else:
            b[i] = 1
            m += 1
    print(m)
    if m:
        print(*b[1:])


main()

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
b=[0]*n
for i in range(n,1,-1):
  if a[i-1]==1:
    
      
      for j in range(1,i+1):
        if i%j==0:
          b[i//j-1]+=1
          b[i//j-1]%=2
          
          
if sum(b)%2!=a[0]:
  b[0]+=1
t=sum(b)
print(t)
if t>0:
  
  print(' '.join(map(str,b)))

Submission status: Wrong Answer

Solution code:
n,*a=map(int,open(0).read().split())
b=[0]*n
for i in range(1,n+1)[::-1]:
  if not sum(b[i-1::i])%2==a[i-1]:
    b[i-1]=1
print(sum(b))
print(*b)

Submission status: Wrong Answer

Solution code:
n,*a=map(int,open(0).read().split())
b=[0]*n
for i in range(1,n+1)[::-1]:
  if not sum(b[i-1::i])%2==a[i-1]:
    b[i-1]=1
print(n)
print(' '.join(map(str,b)))

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int, input().split()))

box = [0 for _ in range(N)]

for i in reversed(range(N)):
    if a[i] == 1:
        box[i] = 1

temp = sum(box)
if temp % 2 != a[0]:
    print(-1)
    exit()

for i in range(1, N):
    temp = sum(box[i:i+1])
    if temp % 2 == a[i]:
        continue
    else:
        print(-1)
        exit()

print(sum(box))
for n, i in enumerate(box):
    if i == 1:
        print(n+1, end="")
    else:
        print(end="")

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int, input().split()))

box = [0 for _ in range(N)]

for i in reversed(range(N)):
    if a[i] == 1:
        box[i] = 1

for i in range(1, N):
    temp = sum(box[i:i])
    if temp % 2 == a[i]:
        continue
    else:
        print(-1)
        exit()

print(sum(box))
for n, i in enumerate(box):
    if i == 1:
        print(n+1, end="")
    else:
        print(end="")

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':
    n = int(input())
    a = list(map(int, input().split()))
    ans = [0] * n
    for i in range(n - 1, -1, -1):
        tmp = 0
        index = 2
        while index * (i + 1) < n:
            tmp += ans[index * (i + 1)]
            index += 1
        if tmp % 2 == a[i]:
            ans[i] = 0
        else:
            ans[i] = 1
    input_ans = []
    print(sum(ans))
    for i in range(n):
        if ans[i] == 1:
            input_ans.append(str(i + 1))
    if not input_ans:
        print(0)
    else:
        print(' '.join(input_ans))

Submission status: Wrong Answer

Solution code:
N=int(input())
a=list(map(int,input().split()))

ball=[0]*N
for i in range(N-1,-1,-1):
  B=ball[i::i+1]
  if sum(B)!=a[i]:
    ball[i]=1

print(sum(ball))
if sum(ball)!=0:
  b=[]
  for i in range(N):
    if ball[i]==1:
      b.append(i+1)
  print(*b)

Submission status: Wrong Answer

Solution code:
N=int(input())
a=list(map(int,input().split()))

ball=[0]*N
for i in range(N-1,-1,-1):
  B=ball[i::i+1]
  if sum(B)!=a[i]:
    ball[i]=1

print(sum(ball))
for i in range(N):
  if ball[i]==1:
    print(i+1)

Submission status: Wrong Answer

Solution code:
N=int(input())
a=list(map(int,input().split()))

ball=[0]*N
for i in range(N-1,-1,-1):
  if a[i]==1:
    B=ball[i::i+1]
    if B.count(1)%2==1:
      continue
    else:
      ball[i]=1

if ball.count(1)==0:
  print(0)
else:
  print(ball.count(1))
  b=[]
  for i in range(N):
    if ball[i]==1:
      b.append(i+1)
  print(*b)

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())

    a = [0]
    a += map(int, input().split())

    b = [0] * (N + 1)

    x = N
    k = 1
    while x > 0:
        while x * (k + 1) > N:
            t = 0
            for j in range(2, k + 1):
                t ^= a[x * j]
            b[x] = a[x] ^ t
            x -= 1
        k += 1

    ans = [i for i, x in enumerate(b) if x == 1]
    print(len(ans))
    print(*ans, sep='\n')


if __name__ == '__main__':
    main()

# import sys
# input = sys.stdin.readline
# 
# sys.setrecursionlimit(10 ** 7)
# 
# (int(x)-1 for x in input().split())
# rstrip()
#
# def binary_search(*, ok, ng, func):
#     while abs(ok - ng) > 1:
#         mid = (ok + ng) // 2
#         if func(mid):
#             ok = mid
#         else:
#             ng = mid
#     return ok

Submission status: Wrong Answer

Solution code:
import sys
input=sys.stdin.readline

n=int(input())
a=list(map(int,input().split()))
b=[0]*n
if n==1:
    b=a
elif n==2:
    b[1]=a[1]
    b[0]=(a[0]-b[1])%2
    
elif n==3:
    b[1]=a[1]
    b[2]=a[2]
    b[0]=(a[0]-b[1]-b[2])%2
else:
  i=2
  while n/i>=2:
      for k in range(n//i,n//(i-1)):
          j=2
          b[k]=a[k]
          while j*(k+1)-1<n:
              b[k]=(b[k]-b[j*(k+1)-1])%2
              j+=1
      i+=1
  j=1
  b[1]=a[1]
  b[0]=a[0]
  while j*1<n:
      if 1+j*2<n:
          b[1]=(b[1]-b[1+j*2])%2
      b[0]=(b[0]-b[j*1])%2
      j+=1
num=sum(b)
print(num)
for i in range(n):
    if b[i]==1:
        print(i+1)

Submission status: Wrong Answer

Solution code:
import sys
input=sys.stdin.readline

n=int(input())
a=list(map(int,input().split()))
b=[0]*n
if n==1:
    b=a
elif n==2:
    b[1]=a[1]
    b[0]=(a[0]-b[1])%2
    
elif n==3:
    b[1]=a[1]
    b[2]=a[2]
    b[0]=(a[0]-b[1]-b[2])%2
else:
  i=2
  while n/i>=2:
      for k in range(n//i,n//(i-1)):
          j=2
          b[k]=a[k]
          while j*(k+1)-1<n:
              b[k]=(b[k]-b[j*(k+1)-1])%2
              j+=1
      i+=1
  j=1
  b[1]=a[1]
  b[0]=a[0]
  while j*1<n:
      if 1+j*2<n:
          b[1]=(b[1]-b[1+j*2])%2
      b[0]=(b[0]-b[j*1])%2
      j+=1
num=0
for i in range(n):
    if b[i]==1:
        print(i+1)
        num+=1
if num==0:
  print(0)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
B = [0 for _ in range(N)]
for i in range(N//2,N-1):
    if A[i] == 1:
        B[i] = 1
FB = B[0:N//2]
SB = B[N//2:N]
S = [i for i in range(1,N//2+1)]
FH = A[0:N//2]
for i in range(1,len(FH)+1):
    s = 0
    for j in range(2,N//S[-i]+1):
        s += B[S[-i]*j-1]
    if s % 2 != FH[-i]:
        FB[-i] = 1
    B = FB + SB
ans = []
for i in range(N):
    if B[i] == 1:
        ans.append(i+1)
print(len(ans))
print(*ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
B = [0 for _ in range(N)]
for i in range(N//2,N-1):
    if A[i] == 1:
        B[i] = 1
FB = B[0:N//2]
SB = B[N//2:N]
S = [i for i in range(1,N//2+1)]
FH = A[0:N//2]
for i in range(1,len(FH)+1):
    s = 0
    for j in range(2,N//S[-i]+1):
        s += B[S[-i]*j-1]
    if s % 2 != FH[-i]:
        FB[-i] = 1
    B = FB + SB
ans = []
for i in range(N):
    if B[i] == 1:
        ans.append(i+1)
if ans == []:
    print(0)
else:
    print(*ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
b=[]
c=0
for i in range(n):
    c+=a[i]%2
    if a[i]%2==1:
        b.append(str(i+1))
if len(b)==0:print(0)
else:
    print(c)
    print(' '.join(b))

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
b=[0]*n
c=0
for i in range(n):
    c+=a[i]%2
    if a[i]%2==1:
        b[i]+=i+1
print(sum(b))
b1=[str(n) for n in b]
print(' '.join(b1))