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:
def main():

    N = int(input())
    a = {i: inp for i, inp in enumerate(map(int, input().split()), 1)}
        
    M = 0
    b = {i : 0 for i in range(1, N+1)}

    for i in range(N, 0, -1):
        sum_multiple = 0
        cursor = 2
        while i * cursor <= N:
            sum_multiple += a[i * cursor]
            cursor += 1

        if a[i] == 1:
            if sum_multiple % 2:
                b[i] = 0
            else:
                b[i] = 1
                M += 1
        else:
            if sum_multiple % 2:
                b[i] = 1
                M += 1
            else:
                b[i] = 0

    b = [str(value) for value in b.values()]
    b = ' '.join(b)

    print(M)
    print(b)

if __name__=="__main__":
    main()

Submission status: Wrong Answer

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

i=n-1
while i>=0:
    if A[i]==1:
        s=i
        break
    i-=1

if i==-1:
    print(0)
elif s==0:
    print(1)
else:
    i=(s+1)//2-1
    while i>=0:
        B=[A[j] for j in range(i,n,i+1)]
        r=sum(B[1:])
        if r%2==0:
            A[i]=1
        else:
            A[i]=0
        i-=1
    C=[m for m,k in enumerate(A,1) if k!=0]
    print(len(C))
    print(*C)

Submission status: Wrong Answer

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

i=n-1
while i>=0:
    if A[i]==1:
        s=i
        break
    i-=1

if i==-1:
    print(0)
elif s==0:
    print(1)
else:
    i=int((s+1)**0.5)
    while i>=0:
        B=[A[j] for j in range(i+1,n,i+1)]
        r=sum(B[1:])
        if r%2==0:
            A[i]=1
        else:
            A[i]=0
        i-=1
    C=[m for m,k in enumerate(A,1) if k!=0]
    print(len(C))
    print(*C)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
input = sys.stdin.readline

n = int(input())
a = list(map(int,input().split()))
ret = [0 for _ in range(n+1)]
#後ろから求める
for i,a_i in enumerate(a[-1::-1]):
    cur_ret_sum = sum(ret[n-i::n-i])%2
    if a_i!=cur_ret_sum:
        ret[n-i]=1
m = sum(ret[1::])
print(m)
if m > 0:
    print(" ".join(map(str,ret[1::])))

Submission status: Wrong Answer

Solution code:
import numpy as np

n = int(input())
A = list(map(int, input().split()))
m = 0
B = []
sum = np.zeros(n, dtype=int)
for i in range(n-1, -1, -1):
  if (sum[i::i+1].sum())%2 ^ A[i]:
    B.append(i+1)
    m += 1
    sum[i::i+1] ^= 1
print(m)
print(*B)

Submission status: Wrong Answer

Solution code:
import numpy as np

n = int(input())
A = list(map(int, input().split()))
m = 0
B = []
sum = np.zeros(n, dtype=int)
for i in range(n-1, -1, -1):
  if sum[i] ^ A[i]:
    B.append(i+1)
    m += 1
    sum[i::i+1] ^= 1
print(m)
print(*B)

Submission status: Wrong Answer

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

ans = []

for i in range(N-1, -1, -1):
  s = sum([A[i] for i in range(i, N, i+1)]) % 2
  if s != A[i]:
    print(-1)
    exit()
  if s == 1:
    ans.append(i+1)

print(len(ans))
if len(ans) > 0: print(*ans)

Submission status: Wrong Answer

Solution code:
import sys

import numpy as np

readline = sys.stdin.buffer.readline


def main():
    N = int(readline())
    A = [0] + list(map(int, readline().split()))
    A = np.array(A)
    C = np.zeros(N + 1, dtype=np.int32)

    if A[-1] == 1:
        C[-1] == 1

    for j in range(N, 0, -1):
        cnt = np.sum(C[j::j])

        if cnt % 2 == 0:
            if A[j] == 0:
                C[j] = 0
            else:
                C[j] = 1
        else:
            if A[j] == 0:
                C[j] = 1
            else:
                C[j] = 0

    print(C)
    ans = np.sum(C)
    print(ans)
    if ans != 0:
        for i, c in enumerate(C):
            if c == 1:
                print(i)


main()

Submission status: Wrong Answer

Solution code:
import sys

import numpy as np

readline = sys.stdin.buffer.readline


def main():
    N = int(readline())
    A = [0] + list(map(int, readline().split()))
    A = np.array(A)
    C = np.zeros(N + 1, dtype=np.int32)

    for i in range(N):
        j = N - i
        cnt = np.sum(C[j::j])

        if cnt % 2 == 0:
            if A[j] == 0:
                C[j] = 0
            else:
                C[j] = 1
        else:
            if A[i] == 0:
                C[j] = 1
            else:
                C[j] = 0

    ans = np.sum(C)
    print(ans)
    if ans != 0:
        for i, c in enumerate(C):
            if c == 1:
                print(i)


main()

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(range(1, N + 1))
    C = []

    for i in range(N - 1, -1, -1):
        cnt = 0
        n = 2
        while B[i] * n <= N:
            cnt += A[B[i] * n - 1]
            n += 1

        if cnt % 2 == 0:
            if A[B[i] - 1] == 0:
                C.append(0)
            else:
                C.append(1)
        else:
            if A[B[i] - 1] == 0:
                C.append(1)
            else:
                C.append(0)

    ans = sum(C)
    print(ans)
    if ans != 0:
        for i, c in enumerate(C[::-1]):
            if c == 1:
                print(i + 1)


main()

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(range(1, N + 1))
    C = []

    for i in range(N - 1, -1, -1):
        cnt = 0
        n = 2
        while B[i] * n <= N:
            cnt += A[B[i] * n - 1]
            n += 1

        if cnt % 2 == 0:
            if A[i] == 0:
                C.append(0)
            else:
                C.append(1)
        else:
            if A[i] == 0:
                C.append(1)
            else:
                C.append(0)

    ans = sum(C)
    print(ans)
    if ans != 0:
        for i, c in enumerate(C[::-1]):
            if c == 1:
                print(i + 1)


main()

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(range(1, N + 1))
    C = []

    for i in range(N - 1, -1, -1):
        cnt = 0
        n = 1
        while B[i] * n <= N:
            cnt += A[B[i] * n - 1]
            n += 1

        C.append(cnt % 2)

    ans = sum(C)
    print(ans)
    if ans != 0:
        for i, c in enumerate(C[::-1]):
            if c == 1:
                print(i + 1)


main()

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    A = list(map(int, input().split()))[::-1]
    B = list(range(1, N + 1))[::-1]
    C = []

    for a, b in zip(A, B):
        n = 1
        cnt = 0
        while b * n <= N:
            cnt += A[N - b * n]
            n += 1

        C.append(cnt % 2)

    print(sum(C))
    if sum(C) != 0:
        for i, c in enumerate(C[::-1]):
            if c == 1:
                print(i + 1)


main()

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    A = list(map(int, input().split()))[::-1]
    B = list(range(1, N + 1))[::-1]
    C = []

    for a, b in zip(A, B):
        n = 1
        cnt = 0
        while b * n <= N:
            cnt += A[N - b * n]
            n += 1

        C.append(cnt % 2)

    print(sum(C))
    if sum(C) != 0:
        print(*C[::-1])


main()

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    A = list(map(int, input().split()))[::-1]
    B = list(range(1, N + 1))[::-1]
    C = []

    for a, b in zip(A, B):
        n = 1
        cnt = 0
        while b * n <= N:
            cnt += A[N - b * n]
            n += 1

        C.append(cnt % 2)

    print(*C[::-1])


main()

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 - 1)
            if i != n // i:
                divisors.append(n//i - 1)
    return divisors

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

N = int(input())
# 1-indexed
a = [int(i) for i in input().split()]

now = [0] * N
for i in range(N-1,-1,-1):
    if now[i] != a[i]:
        div = make_divisors(i+1)
        for j in div:
            now[j] += 1
            now[j] %= 2

M = now.count(1)
print(M)

answer = [i+1 for i,x in enumerate(now) if x == 1]
if M > 0:
    print(" ".join(list(map(str,answer))))

Submission status: Wrong Answer

Solution code:
def main():
    n = int(input())
    a_list = [-1]
    a_list += list(map(int, input().split()))

    bolls = [-1] * (n + 1)
    m = 0
    for i in range(n, 0, -1):
        count = 0
        for j in range(2, n):
            multiple = i * j
            if multiple > n:
                break
            else:
                count += bolls[multiple]
        temp = count % 2
        if a_list[i] != temp:
            bolls[i] = 1
            m += 1
        else:
            bolls[i] = 0

    print(m)
    ans_list = []
    for i in range(1, n + 1):
        if bolls[i] >= 1:
            ans_list.append(i)
    print(' '.join(map(str, ans_list)))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
ans = [-1] * n
curr_n = n
sum_n = 0
cnt = 0
while sum_n < n:
    if curr_n != 1:
        curr_n = (curr_n) // 2 
    cnt += 1
    for i in range(n - sum_n - curr_n, n-sum_n):
        tmp_sum = 0
        for j in range(0, cnt):
            tmp_sum += a[i * (j + 1)]
        ans[i] = tmp_sum % 2
#         print(i, tmp_sum)
    sum_n += curr_n
print(sum(ans))
for i in range(len(ans)):
    if ans[i] != 0:
        print(i, end = ' ')

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
b = [-1] * (n + 1)
a.insert(0, 0)
for i in range(n, 0, -1):
    t_sum = 0
    j = 2 * i
    while j <= n:
        t_sum ^= b[j]
        j += i
    b[i] = t_sum ^ a[i]
print(sum(b[1:]))
for i in range(1, n + 1):
    if b[i] != 0:
        print(1)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
ans = [-1] * n
curr_n = n
sum_n = 0
cnt = 0
while sum_n < n:
    if curr_n != 1:
        curr_n = (curr_n) // 2 
    cnt += 1
    for i in range(n - sum_n - curr_n, n-sum_n):
        tmp_sum = 0
        for j in range(0, cnt):
            tmp_sum += a[i * (j + 1)]
        ans[i] = tmp_sum % 2
#         print(i, tmp_sum)
    sum_n += curr_n
print(sum(ans))
for i in range(len(ans)):
    if ans[i] != 0:
        print(1)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
ans = [-1] * n
curr_n = n
sum_n = 0
cnt = 0
while sum_n < n:
    if curr_n != 1:
        curr_n = (curr_n) // 2 
    cnt += 1
    for i in range(n - sum_n - curr_n, n-sum_n):
        tmp_sum = 0
        for j in range(0, cnt):
            tmp_sum += a[i * (j + 1)]
            print(tmp_sum)
        ans[i] = tmp_sum % 2
#         print(i, tmp_sum)
    sum_n += curr_n
print(sum(ans))
for i in range(len(ans)):
    if ans[i] != 0:
        print(1)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
if sum(a) == 0:
    print(0)
    exit()
print(sum(a))
for i in range(len(a)):
    if a[i] != 0:
        print(1, end = ' ')

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
if sum(a) == 0:
    print(-1)
    exit()
print(sum(a))
for i in range(len(a)):
    if a[i] != 0:
        print(1, end = ' ')

Submission status: Wrong Answer

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


def main():
    n = int(input())
    a = [int(_) for _ in input().split()]
    l = [0 for _ in range(n)]
    for i in range(n-1, -1, -1):
        re_i = i + 1
        for j in range(0, n//re_i):
            res = 0
            re_j = j + 1
            res += l[(re_i * re_j) - 1]
            if res // 2 != a[i]:
                l[i] = 1
    # print(l)
    ans = []
    for i in range(len(l)):
        if l[i] == 1:
            ans.append(i + 1)
    print(len(ans))
    if len(ans) == 0:
        sys.exit()
    else:
        print(" ".join(map(str, ans)))
            


if __name__ == '__main__':
    main()

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):
    sum = 0
    for j in range(i*2, N+1, i):
        sum += b[i-1]
    if sum % 2 == 0:
        b[i-1] = a[i-1]
    else:
        b[i-1] = 1 - a[i-1]
count = b.count(1)
print(b.count(1))
if count > 0:
    ans = ''
    for i in range(1, N+1):
        if b[i-1] == 1:
            ans += str(i) + ' '
    print(ans[:-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):
    sum = 0
    for j in range(i*2, N, i):
        sum += b[i-1]
    if sum % 2 == 0:
        b[i-1] = a[i-1]
    else:
        b[i-1] = 1 - a[i-1]
count = b.count(1)
print(b.count(1))
if count > 0:
    ans = ''
    for i in range(1, N+1):
        if b[i-1] == 1:
            ans += str(i) + ' '
    print(ans[:-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):
    sum = 0
    for j in range(i*2, N, i):
        sum += b[i-1]
    b[i-1] = a[i-1] - (sum % 2)
count = b.count(1)
print(b.count(1))
if count > 0:
    ans = ''
    for i in range(1, N+1):
        if b[i-1] == 1:
            ans += str(i) + ' '
    print(ans[:-1])

Submission status: Wrong Answer

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

a = [0] + a
b = [0] * (n+1)

for i in range(n, 0, -1):
    sum = 0
    for j in range(i, n, i):
        sum ^= b[j]
    b[i] = sum^a[i]


ans = list()
for i in range(n+1):
    if b[i]: ans.append(i)

print(len(ans))
if len(ans) != 0:
    print(*ans)

Submission status: Wrong Answer

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

a = [0] + a
b = [0] * (n+1)

for i in range(n, 0, -1):
    sum = 0
    for j in range(i+i, n, i):
        sum ^= b[j]
    b[i] = sum^a[i]


ans = list()
for i in range(n+1):
    if b[i]: ans.append(i)

print(len(ans))
if len(ans) != 0:
    print(*ans)

Submission status: Wrong Answer

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

a = [0] + a
b = [0] * (n+1)

for i in range(n, 0, -1):
    sum = 0
    for j in range(i+i, n, i):
        sum ^= b[j]
    b[i] = sum^a[i]


ans = list()
for i in range(n+1):
    if b[i]: ans.append(i)

print(len(ans))
print(*ans)

Submission status: Wrong Answer

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


def preparing_boxes(N: int, A: list)->list:
    B = []

    for i in range(N, 0, -1):
        a = A[i-1]
        if a == 0:
            continue
        B.append(i)

        for div in divisors(a):
            A[div-1] = 1 - A[div-1]

    return B


if __name__ == "__main__":
    N = int(input())
    A = list(map(int, input().split()))
    ans = preparing_boxes(N, A)
    print(len(ans))
    print(' '.join(str(i) for i in ans))

Submission status: Wrong Answer

Solution code:
n=int(input())
a=[0]+list(map(int,input().split()))
ball=[0]*(n+1)
for i in range(n,0,-1):
    c=1
    sum=0
    while c*i<=n:
        sum+=ball[c*i]
        c+=1
    ball[i]=sum%2+a[i]
ans=[]
for i in range(1,n+1):
    if ball[i]!=0:
        ans.append(i)
print(len(ans))
"""if len(ans)==0:
    exit()"""
print(*ans)

Submission status: Wrong Answer

Solution code:
from sys import stdin

n = int(stdin.readline().rstrip())
li = [0] + list(map(int,stdin.readline().rstrip().split()))
lin = [0]*(n+1)
lis = []
point = 0
for i in range(n//2,0,-1):
    goukei = sum(lin[i::i])%2
    if goukei != li[i]:
        lin[i] = 1
        point += 1
        lis.append(i)

print(point)
lis.sort()
for i in lis:
    print(i)

Submission status: Wrong Answer

Solution code:
from sys import stdin

n = int(stdin.readline().rstrip())
li = [0] + list(map(int,stdin.readline().rstrip().split()))
lin = [0]*(n+1)
lis = []
point = 0
for i in range(n//2,0,-1):
    goukei = sum(lin[i*2::i])%2
    if goukei != li[i]:
        lin[i] = 1
        point += 1
        lis.append(i)

print(point)
lis.sort()

for i in lis:
    print(i)

Submission status: Wrong Answer

Solution code:
from sys import stdin

n = int(stdin.readline().rstrip())
li = [0] + list(map(int,stdin.readline().rstrip().split()))
lin = [0]*(n+1)
lis = []
point = 0
for i in range(n//2,0,-1):
    goukei = sum(lin[i*2::i])
    if goukei != li[i]:
        lin[i] = 1
        point += 1
        lis.append(i)

print(point)
lis.sort()

for i in lis:
    print(i)

Submission status: Wrong Answer

Solution code:
from sys import stdin

n = int(stdin.readline().rstrip())
li = [0] + list(map(int,stdin.readline().rstrip().split()))
lin = [0]*(n+1)
lis = []
point = 0
for i in range(n,0,-1):
    goukei = sum(lin[i*2::i])
    if goukei != li[i]:
        lin[i] = 1
        point += 1
        lis.append(i)
print(point)
lis.sort()
for i in lis:
    print(i)

Submission status: Wrong Answer

Solution code:
from sys import stdin

n = int(stdin.readline().rstrip())
li = [0] + list(map(int,stdin.readline().rstrip().split()))
lin = []
point = 0

for i in range(n,0,-1):
    goukei = sum(li[i*2::i])
    if goukei != li[i]:
        li[i] = 1
        point += 1
        lin.append(i)
print(point)
lin.sort()
for i in lin:
    print(i)

Submission status: Wrong Answer

Solution code:
from sys import stdin

n = int(stdin.readline().rstrip())
li = [0] + list(map(int,stdin.readline().rstrip().split()))
lin = []
point = 0

for i in range(n,0,-1):
    goukei = sum(li[i::i])%2
    if goukei != li[i]:
        point += 1
        lin.append(i)
print(point)
lin.sort()
for i in lin:
    print(i)

Submission status: Wrong Answer

Solution code:
from sys import stdin

n = int(stdin.readline().rstrip())
li = [0] + list(map(int,stdin.readline().rstrip().split()))
lin = []
point = 0

for i in range(n,0,-1):
    goukei = sum(li[i::i])%2
    if goukei == 1 and li[i] == 0:
        li[i] = 1
        point += 1
        lin.append(i)
    elif goukei == 1 and li[i] == 1:
        point += 1
        lin.append(i)
print(point)
lin.sort()
for i in lin:
    print(i)

Submission status: Wrong Answer

Solution code:
from sys import stdin

n = int(stdin.readline().rstrip())
li = [0] + list(map(int,stdin.readline().rstrip().split()))
lin = []
point = 0

for i in range(n,0,-1):
    goukei = sum(li[i::i])%2
    if goukei == 1 and li[i] == 0:
        li[i] = 1
        point += 1
        lin.append(i)
    elif goukei == 1 and li[i] == 1:
        point += 1
        lin.append(i)
print(point)
for i in lin:
    print(i)

Submission status: Wrong Answer

Solution code:
from sys import stdin

n = int(stdin.readline().rstrip())
li = [0] + list(map(int,stdin.readline().rstrip().split()))
lin = []
point = 0

for i in range(n,0,-1):
    goukei = sum(li[i::i])%2
    if goukei == 1:
        li[i] = 1
        point += 1
        lin.append(i)
print(point)
for i in lin:
    print(i)

Submission status: Wrong Answer

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

ans=set()
for i in range(n-1,-1,-1):
  for j in range(i+1,n+1,i+1):
    if j in ans:
      A[i]+=1
    if A[i]%2:
      ans.add(i+1)
print(len(ans))
print(*ans)

Submission status: Wrong Answer

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

ans=[]
balls=[0]*n
for i in range(n-1,-1,-1):
  if A[i]!=0:
    total=0
    for j in range(n-1,i-1,i+1):
      total+=A[j]
    if total%2!=A[i]:
      if total+1!=A[i]:
        print(-1)
        exit()
      balls[i]+=1
      ans.append(i+1)
print(sum(balls))
print(*ans,sep=' ')

Submission status: Wrong Answer

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

ans=[]
balls=[0]*n
for i in range(n-1,-1,-1):
  if A[i]!=0:
    total=0
    for j in range(n-1,i,A[i]):
      total+=A[j]
    if total%2!=A[i]:
      if total+1!=A[i]:
        print(-1)
        exit()
      balls[i]+=1
      ans.append(i+1)
print(sum(balls))
print(*ans,sep=' ')

Submission status: Wrong Answer

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

boxes = [0]*N
for i in reversed(range(N)):
    num_balls = 0
    for k in range(i, N, i+1):
        num_balls += boxes[k]
    if num_balls%2 != a[i]:
        boxes[i] = 1

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

Submission status: Wrong Answer

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

def search(x):
    n = 1
    res = 0
    while True:
        nx = n*x
        if nx > N:
            break
        res += boxes[nx-1]
        n += 1
    return res%2


boxes = [0]*N
for i, ai in enumerate(a):
    i = N-i
    eo = search(i)
    if ai!=eo:
        boxes[i-1]=1

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

if ans==[]:
    print(0)
else:
    ans = list(map(lambda x:x+1, ans))
    print(*ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int,input().split()))
ans = []
def divisor(n):
  ret = [0]
  for i in range(2,int(n**(1/2))+1):
    if n%i==0:
      n//=i
      ret.append(i-1)
      while n%i==0:
        n//=i
      
  ret.append(n-1)
  return ret

for i in reversed(range(N)):
  if a[i]:
    ans.append(i+1)
    lis = divisor(i+1)
    for j in lis:
      a[j]^=1
      
l = len(ans)
if l>0:
  print(l)
  print(*ans)
else:
  print(l)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
M = 0
B = []
for i in reversed(range(N)):
    tmp = 0
    for k in range(i, N, i+1):
        tmp += A[k]
    if tmp % 2 == 1:
        M += 1
        B.insert(0, i+1)
print(M)
for i in range(M):
    print(B[i])

Submission status: Wrong Answer

Solution code:
N=int(input())
a=list(map(int,input().split()))
ball=[]
for i in range(len(a)):
  if a[i]==1:
    ball.append(i+1)

print(len(ball))
for c in ball:
  print(c)

Submission status: Wrong Answer

Solution code:
N=int(input())
a=list(map(int,input().split()))
ball=[]
for i in range(len(a)):
  if a[i]==1:
    ball.append(i+1)

if len(ball)>N:
  print(-1)
else:
  print(len(ball))
  for c in ball:
    print(c)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int,input().split()))
a = [-1] + a
count = 0

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

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int,input().split()))
print(-1)

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int,input().split()))
B=[0 for i in range(N)]
M=0

for n in range(N,0,-1):
    K=N//(n)
    for m in range(K):
        if m==0:
            B[n-1]+=A[n-1]
        else:
            B[n-1]+=B[n-1+n*m]
    B[n-1]%=2
    M+=B[n-1]

print(M)
"""while B and B[-1]==0:
    B.pop()"""
if B:
    print(" ".join([str(i) for i in B]))

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int,input().split()))
B=[0 for i in range(N)]
M=0

for n in range(N,0,-1):
    K=N//n
    for m in range(K):
        if m==0:
            B[n-1]+=A[n-1]
        else:
            B[n-1]+=B[n-1+n*m]
    B[n-1]%=2
    M+=B[n-1]

print(M)
while B and B[-1]==0:
    B.pop()
if B:
    print(" ".join([str(i) for i in B]))

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int,input().split()))
B=[0 for i in range(N)]
M=0

for n in range(N,0,-1):
    K=N//n
    for m in range(K):
        B[n-1]+=A[n-1+n*m]
    B[n-1]%=2
    M+=B[n-1]

print(M)
while B and B[-1]==0:
    B.pop()
if B:
    print(" ".join([str(i) for i in B]))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N=int(input())
li=input().split()
a=0
list2=[0]*N
for i in range(N,0,-1):
        s=0
        for t in range(i,N+1,i):
                s+=t
        if li[i-1]==1:
                if s%2==0:
                        list2[i-1]=1
                        a+=1
        if li[i-1]==0:
                if s%2==1:
                        list2[i-1]=1
                        a+=1
list2=list(map(str,list2))
print(a)
if a!=0:
        print(" ".join(list2))

Submission status: Wrong Answer

Solution code:
import sys

input = sys.stdin.readline

def main(): 
    N = int(input())
    A = [0] + list(map(int, input().split()))
    
    ans = [0] * (N+1)
    c = 0
    for i in range(N, 0, -1):
        t = sum(ans[i::i])
            
        if A[i] != (t%2): 
            ans[i] = 1
            c += 1
            
    print(c)
    print('1 '*c)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [num for num in map(int, input().split(' '))]

# print(n, a)

ans = [0] * (n+1)

for i in range(n):
  # 後ろから走査するための index
  target_i = n - i
  a_targt = a[n-i-1]
  
  # a の倍数の箱のボールの個数を計算
  baisu = 2
  ball_count = 0
  while True:
    baisu_i = target_i * baisu
    if baisu_i > n:
      break
    if ans[baisu_i]:
      ball_count += 1
    baisu += 1
  # 倍数の箱のボールの総数 % 2 が a[i]と異なる場合、箱にボールを入れる必要がある
  if ball_count % 2 != a_targt:
    ans[target_i] = 1

ans_array = []

for i in range(n):
  if ans[i] == 1:
    ans_array.append(i)
print(len(ans_array))
if len(ans_array) > 0:
  print(' '.join(map(str, ans_array)))
# print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [num for num in map(int, input().split(' '))]

# print(n, a)

ans = [0] * (n+1)

for i in range(n):
  # 後ろから走査するための index
  target_i = n - i
  a_targt = a[n-i-1]
  
  # a の倍数の箱のボールの個数を計算
  baisu = 2
  ball_count = 0
  while True:
    baisu_i = target_i * baisu
    if baisu_i >= n:
      break
    if ans[baisu_i]:
      ball_count += 1
    baisu += 1
  # 倍数の箱のボールの総数 % 2 が a[i]と異なる場合、箱にボールを入れる必要がある
  if ball_count % 2 != a_targt:
    ans[target_i] = 1

ans_array = []

for i in range(n):
  if ans[i] == 1:
    ans_array.append(i)
print(len(ans_array))
if len(ans_array) > 0:
  print(' '.join(map(str, ans_array)))
# print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [num for num in map(int, input().split(' '))]

# print(n, a)

ans = [0] * (n+1)

for i in range(n):
  # 後ろから走査するための index
  target_i = n - i
  a_targt = a[n-i-1]
  
  # a の倍数の箱のボールの個数を計算
  baisu = 2
  ball_count = 0
  while True:
    baisu_i = target_i * baisu
    if baisu_i >= n:
      break
    if ans[baisu_i]:
      ball_count += 1
    baisu += 1
  # 倍数の箱のボールの総数 % 2 が a[i]と異なる場合、箱にボールを入れる必要がある
  if ball_count % 2 != a[i]:
    ans[i] = 1

ans_array = []

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

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
c = [0]
d = c + a
s = [0 for i in range(n + 1)]
 
for i in range(n, 0, -1):
    w = 0
    for j in range(2 * i, n + 1, i):
        w ^= s[j]
    s[i] = (w ^ d[i])
print(sum(s))
for i in range(1, n + 1):
    if s[i]:
        print(s[i],end=' ')

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
c = [0]
d = c + a
s = [0 for _ in range(n + 1)]

for i in range(n, 0, -1):
    w = 0
    for j in range(2 * i, n + 1, i):
        w ^= s[j]
    s[i] = w ^ d[i]

print(s.count(1) if s.count(1) else 0)
for i in range(1, n + 1):
    if s[i] != 0:
        print(s[i], end=' ')

Submission status: Wrong Answer

Solution code:
n=int(input())
A=list(map(int,input().split()))
B=[0 for i in range(n+1)]
C=[]
cnt=0
for i in range(1,n+1)[::-1]:
    sum_B=sum(B[j] for j in range(i,n+1,i))
    if sum_B%2!=A[i-1]:
        C.append(i)
        cnt +=1
print(cnt)
print(*[i for i in C[::-1]])

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
c = [0]
d = c + a
s = [0 for _ in range(n + 1)]

for i in range(n, 0, -1):
    w = 0
    for j in range(2 * i, n + 1, i):
        w ^= s[j]
    s[i] = w ^ d[i]

print(sum(s))
for i in range(1, n + 1):
    if s[i] != 0:
        print(s[i], end=' ')