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 heapq
from collections import defaultdict
cnt = defaultdict(int)
N = int(input())
A = list(map(int, input().split()))
# A = []
# for i in range(N):
#     A.append(int(input()))
ans = 0
_ans = []
buff = [0 for i in range(N)]
for i in range(N-1, -1, -1):
    if i > N//2:
        buff[i] = A[i]
    else:
        _m = 0
        # for j in range(i, N, max(1, i)):
        #     _m += buff[j]
        # _m = sum(buff[i:N])
        for j in range(i*2, N, max(1, i)):
            _m += buff[j]
        if _m % 2 != A[i]:
            buff[i] = 1
            ans += 1
            _ans.append(i+1)

mm = 0
for i in range(ans):
    if buff[i] == 1:
        mm = i

print(sum(buff))
print(*_ans)
# print(*buff[:i])

# https://atcoder.jp/contests/abc134/submissions/6480053

Submission status: Wrong Answer

Solution code:
import heapq
from collections import defaultdict
cnt = defaultdict(int)
N = int(input())
A = list(map(int, input().split()))
# A = []
# for i in range(N):
#     A.append(int(input()))
ans = 0
_ans = []
buff = [0 for i in range(N)]
for i in range(N-1, -1, -1):
    _m = 0
    # for j in range(i, N, max(1, i)):
    #     _m += buff[j]
    _m = sum(buff[i:N])
    if _m % 2 != A[i]:
        buff[i] = 1
        ans += 1
        _ans.append(i+1)

mm = 0
for i in range(ans):
    if buff[i] == 1:
        mm = i

print(sum(buff))
print(*_ans)
# print(*buff[:i])

Submission status: Wrong Answer

Solution code:
import heapq
from collections import defaultdict
cnt = defaultdict(int)
N = int(input())
A = list(map(int, input().split()))
# A = []
# for i in range(N):
#     A.append(int(input()))
ans = 0
_ans = []
buff = [0 for i in range(N)]
for i in range(N-1, -1, -1):
    _m = 0
    for j in range(i, N, max(1, i)):
        _m += buff[j]

    if _m % 2 != A[i]:
        buff[i] = 1
        ans += 1
        _ans.append(i+1)

mm = 0
for i in range(ans):
    if buff[i] == 1:
        mm = i

print(sum(buff))
print(*_ans)
# print(*buff[:i])

Submission status: Wrong Answer

Solution code:
import heapq
from collections import defaultdict
cnt = defaultdict(int)
N = int(input())
A = list(map(int, input().split()))
# A = []
# for i in range(N):
#     A.append(int(input()))
ans = 0
_ans = []
buff = [0 for i in range(N)]
for i in range(N-1, -1, -1):
    _m = 0
    for j in range(i, N, max(1, i)):
        _m += buff[j]

    if _m % 2 != A[i]:
        buff[i] = 1
        ans += 1
        _ans.append(i+1)

mm = 0
for i in range(ans):
    if buff[i] == 1:
        mm = i

print(ans)
print(*_ans)
# print(*buff[:i])

Submission status: Wrong Answer

Solution code:
import sys

a = int(input());
b = list(map(int,input().split()));
c=0;
d=[];
for i in range(len(b)):
    #c+=b[len(b)-i-1];
    for j in range(int(len(b)/len(b)-i)):
        c += b[(len(b)-i)*j-1];
    if c%2 == b[i]:
        d.append(i+1);
        #print(d);

print(len(d));
for i in range(len(d)):
    if i == len(d)-1:
        print(d[i])
    else:
        print(d[i],end=" ")

Submission status: Wrong Answer

Solution code:
from sys import stdin

def main():
    N = int(input())
    A = list(map(int, input().split()))

    a = [-1] + A
    ans = []
    ball = [0] * (N + 1)
    for i in range(N, 0, -1):
        j = i * 2
        if j <= N:
            if a[i] % 2 != ball[j] % 2:
                ball[i] = ball[j] + 1
                ans.append(i)
            else:
                ball[i] = ball[j]
        else:
            if a[i] % 2:
                ball[i] = 1
                ans.append(i)
    print(len(ans))
    if ans:
        print(*ans)

input = lambda: stdin.readline()
main()

Submission status: Wrong Answer

Solution code:
N = int(input())

A = list(map(int, input().split()))

B = []
balls = [0] * N

for i in range(N-1, -1, -1):
    
    j = i+1
    x = 2
    _sum = 0
    while (j * x <= N):
        _sum += balls[i*x]
        x += 1

    _sum = _sum % 2

    if _sum ^ A[i]:
        balls[i] = 1
        B.append(j)

if B:
    print(len(B))
    print(' '.join(map(str, B)))
else:
    print(0)

Submission status: Wrong Answer

Solution code:
N = int(input())

A = list(map(int, input().split()))

B = []
balls = [0] * N

for i in range(N-1, -1, -1):
    
    j = i+1
    x = 2
    _sum = 0
    while (j * x <= N):
        _sum += balls[i*x]
        x += 1

    _sum = _sum % 2

    if _sum ^ A[i]:
        B.append(j)

if B:
    print(len(B))
    print(' '.join(map(str, B)))
else:
    print(0)

Submission status: Wrong Answer

Solution code:
N = int(input())

A = list(map(int, input().split()))

B = []
balls = [0] * N

for i in range(N-1, -1, -1):
    
    j = i+1
    x = 2
    _sum = 0
    while (j * x <= N):
        _sum += balls[i*x]
        x += 1

    _sum = _sum % 2

    if _sum ^ A[i]:
        B.append(1)

if B:
    print(len(B))
    print(' '.join(map(str, B)))
else:
    print(0)

Submission status: Wrong Answer

Solution code:
N = int(input())
arr = list(map(int, input().split()))
ans_list = [0] * (N)
ans = []
for i in range(N):
    summ = 0
    j = N - 1
    if j != 0:
        while j < N:
            j = j + N - i
            if j < N:
                summ += ans_list[j-1]
    else:
        summ = sum(ans_list)
    if (summ % 2) != arr[N - i - 1]:
        ans_list[N - i - 1] = 1
        ans.append(N - i)

ans.sort()
print(len(ans))
for i in range(len(ans)):
    if i == len(ans)-1:
        print(ans[i])
    else:
        print(ans[i],'', end="")

Submission status: Wrong Answer

Solution code:
N = int(input())
arr = list(map(int, input().split()))
ans_list = [0] * (N)
ans = []
for i in range(N):
    summ = 0
    j = N - 1
    if j != 0:
        while j < N:
            j = j + N - i
            if j < N:
                summ += ans_list[j-1]
    else:
        summ = sum(ans_list)
    if (summ % 2) != arr[N - i - 1]:
        ans_list[N - i - 1] = 1
        ans.append(N - i)

print(len(ans))
for i in range(len(ans)):
    if i == len(ans)-1:
        print(ans[i])
    else:
        print(ans[i],'', end="")

Submission status: Wrong Answer

Solution code:
import heapq
from collections import defaultdict
cnt = defaultdict(int)
N = int(input())
A = list(map(int, input().split()))
# A = []
# for i in range(N):
#     A.append(int(input()))
ans = 0

buff = [0 for i in range(N)]
for i in range(N-1, -1, -1):
    _m = 0
    for j in range(i, N, max(1, i)):
        _m += buff[j]

    if _m % 2 != A[i]:
        buff[i] = 1
        ans += 1

mm = 0
for i in range(ans):
    if buff[i] == 1:
        mm = i

print(ans)
print(*buff[:i])

Submission status: Wrong Answer

Solution code:
N = int(input())
arr = list(map(int, input().split()))
ans_list = [0] * (N)
ans = []
for i in range(N):
    summ = 0
    j = N - i - 1
    if j != 0:
        while j < N:
            j = j + N - i - 1
            if j < N:
                summ += ans_list[j]
    else:
        summ = sum(ans_list)
    if (summ % 2) != arr[N - i - 1]:
        ans_list[N - i - 1] = 1
        ans.append(arr[N - i - 1])

print(len(ans))
for i in range(len(ans)):
    if i == len(ans)-1:
        print(ans[i])
    else:
        print(ans[i],'', end="")

Submission status: Wrong Answer

Solution code:
N = int(input())
arr = list(map(int, input().split()))
ans_list = [0] * (N)
ans = []
for i in range(N):
    summ = 0
    j = N - i - 1
    if j != 0:
        while j < N:
            j = j + N - i - 1
            if j < N:
                summ += ans_list[j]
    else:
        summ = sum(ans_list)
    if (summ % 2) != arr[N - i - 1]:
        ans_list[N - i - 1] = 1
        ans.append(arr[N - i - 1])

print(len(ans))
for i in range(len(ans)):
    if i == len(ans)-1:
        print(ans[i])
    else:
        print(ans[i],' ', end="")

Submission status: Wrong Answer

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

for i in range(n//2, 0, -1):
  if(a[i-1] != sum(b[i-1::i])%2):
    b[i-1] = 1 - a[i-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()))

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

    if total % 2 == A[i]:
        M[i] = 0
    else:
        M[i] = 1


print(sum(M))

kugiri = False
for i in range(len(M)):
    if M[i] == 1:
        if kugiri:
            print(" ", end="")
        print(i+1, end="")
        kugiri = True
print()

Submission status: Wrong Answer

Solution code:
import heapq
from collections import defaultdict
cnt = defaultdict(int)
N = int(input())
A = list(map(int, input().split()))
# A = []
# for i in range(N):
#     A.append(int(input()))
ans = 0

buff = [0 for i in range(N)]
for i in range(N-1, -1, -1):
    _m = 0
    for j in range(i, N, max(1, i)):
        _m += buff[j]

    if _m % 2 != A[i]:
        buff[i] = 1
        ans += 1

print(ans)
print(*buff[:ans])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
arr = list(map(int, input().split()))
ans_list = [0] * (N)
ans = []
for i in range(N):
    summ = 0
    j = N - i - 1
    if j != 0:
        while j < N:
            j = j + N - i - 1
            if j < N:
                summ += ans_list[j]
    else:
        summ = sum(ans_list)
    if (summ % 2) != arr[N - i - 1]:
        ans_list[N - i - 1] = 1
        ans.append(arr[N - i - 1])

print(sum(ans))
for i in range(len(ans)):
    if i == len(ans)-1:
        print(ans[i])
    else:
        print(ans[i],' ', end="")

Submission status: Wrong Answer

Solution code:
N = int(input())
arr = list(map(int, input().split()))
ans_list = [0] * (N)
ans = []
for i in range(N):
    summ = 0
    j = N - i - 1
    if j != 0:
        while j < N:
            j = j + N - i - 1
            if j < N:
                summ += ans_list[j]
    else:
        summ = sum(ans_list)
    if (summ % 2) != arr[N - i - 1]:
        ans_list[N - i - 1] = 1
        ans.append(arr[N - i - 1])

for i in range(len(ans)):
    if i == len(ans)-1:
        print(ans[i])
    else:
        print(ans[i],' ', end="")

Submission status: Wrong Answer

Solution code:
N = int(input())
arr = list(map(int, input().split()))
ans_list = [0] * (N)
ans = []
for i in range(N):
    summ = 0
    j = N - i - 1
    if j != 0:
        while j < N:
            j = j + N - i - 1
            if j < N:
                summ += ans_list[j]
    else:
        summ = sum(ans_list)
    if (summ % 2) != arr[N - i - 1]:
        ans_list[N - i - 1] = 1
        ans.append(arr[N - i - 1])

print(sum(ans))
for i in range(len(ans)):
    print(ans[i],' ', end="")

Submission status: Wrong Answer

Solution code:
import heapq
from collections import defaultdict
cnt = defaultdict(int)
N = int(input())
A = list(map(int, input().split()))
# A = []
# for i in range(N):
#     A.append(int(input()))
ans = 0

buff = [0 for i in range(N)]
for i in range(N-1, -1, -1):
    _m = 0
    for j in range(i, N, max(1, i)):
        _m += buff[j]

    if _m % 2 != A[i]:
        buff[i] = 1
        ans += 1

print(ans)
print(*buff)

Submission status: Wrong Answer

Solution code:
N = int(input())
arr = list(map(int, input().split()))
ans_list = [0] * (N)
ans = []
for i in range(N):
    summ = 0
    j = N - i - 1
    if j != 0:
        while j < N:
            j = j + N - i - 1
            if j < N:
                summ += ans_list[j]
    else:
        for i in range(N):
            summ = sum(ans_list)
    if (summ % 2) != arr[N - i - 1]:
        ans_list[N - i - 1] = 1
        ans.append(arr[N - i - 1])

print(sum(ans))
for i in range(len(ans)):
    print(ans[i],' ', end="")

Submission status: Wrong Answer

Solution code:
N = int(input())
arr = list(map(int, input().split()))
ans_list = [0] * (N)
ans = []
summ = 0
for i in range(N):
    j = N-i
    l = 2
    while j < N:
        j = j + j
        if j < N:
            summ += ans_list[j]
        l += 1
    if (summ % 2) != arr[i]:
        ans_list[i] = 1
        ans.append(arr[i])

print(sum(ans))
for i in range(len(ans)):
    print(ans[i],' ', end="")

Submission status: Wrong Answer

Solution code:
N = int(input())
arr = list(map(int, input().split()))
ans_list = [0] * (N)
ans = []
summ = 0
for i in range(N):
    j = N-i
    l = 2
    while j < N:
        j = j + j
        if j < N:
            summ += arr[j]
        l += 1
    if (summ % 2) != arr[i]:
        ans_list[i] = 1
        ans.append(arr[i])

print(sum(ans))
for i in range(len(ans)):
    print(ans[i],' ', end="")

Submission status: Wrong Answer

Solution code:
def d_preparing_boxes(N, A):
    balls = [0] * N

    for i in range(N, 0, -1):
        t = i
        while t <= N:
            if balls[i - 1] % 2 != A[i - 1]:
                balls[i - 1] += 1
            t += i
    ans = [k for k, b in enumerate(balls, 1) if b != 0]
    return '\n'.join(map(str, [len(ans)] + ans)) if len(ans) != 0 else 0

N = int(input())
A = [int(i) for i in input().split()]
print(d_preparing_boxes(N, A))

Submission status: Wrong Answer

Solution code:
#素数判定
N=int(input())
A=[int(i) for i in input().split()]
n=1

if A[0]==0:
	if A.count("1")==0:
		print("0")
	else:
		print("-1")
else:
	if A.count(1)>2:print("-1")
	elif A.count(1)==1:
		print("1")
		print("1")
	else:
		A[0]=int("0")
		p=A.index(1)+1
		while True:
			n+=1
			if p//2+1==n:
				print("2")
				print("1",p)
				break
			if p%n==0:
				print("-1")
				break

Submission status: Wrong Answer

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

j = 0
while i>0:
    sum1=0
    j = i + i
    while j<=N:
        sum1 += B[j-1]
        sum1=(sum1+2)%2
        j=j+i
    B[i-1]+=(A[i-1]+sum1)
    B[i-1]=(B[i-1]+2)%2
    print(B[i-1])
    i=i-1
count=0
for s in B:
  if s == 1 :
    count+=1
print(count)
for i in range(N):
  if B[i]==1:
    print(i+1,end=" ")

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    A = list(map(int, input().split()))
    A.insert(0, None)
    M = list()

    for i in range(N, 0, -1):
        if N // i <= 1 and A[i] == 1:
            M.append(i)
        else:
            tmp = 0
            for j in range(1, N // i):
                if M.__contains__(i * j):
                    tmp += 1
            if tmp % 2 ^ A[i] == 1:
                M.append(i)

    M.reverse()

    if len(M) == 0:
        print(0)
    else:
        print(len(M))
        for v in M:
            print(v)

    return


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
#素数判定
N=int(input())
A=[int(i) for i in input().split()]
n=1

if A[0]==0:
	if A.count("1")==0:
		print("0")
	else:
		print("-1")
else:
	if A.count(1)>2:print("-1")
	elif A.count(1)==1:
		print("1")
		print("1")
	else:
		A[0]=int("0")
		p=A.index(1)+1
		while True:
			n+=1
	
			if p//2+1==n:
				print("2")
				print("1 ",p)
				break
			if p%n==0:
				print("-1")
				break

Submission status: Wrong Answer

Solution code:
#素数判定
N=int(input())
A=[int(i) for i in input().split()]
n=1

if A[0]==0:
	if A.count("1")==0:
		print("0")
	else:
		print("-1")
else:
	if A.count(1)>2:print("-1")
	elif A.count(1)==1:
		print("1")
		print("1")
	else:
		A[0]=int("0")
		p=A.index(1)+1
		while True:
			n+=1
	
			if p//2+1==n:
				print("2")
				print("1")
				print(p)
				break
			if p%n==0:
				print("-1")
				break

Submission status: Wrong Answer

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

n = int(input())
num_list = [ int(v) for v in input().split() ]
ans_list = [ 0 ] * n

for i in range(n-1,-1,-1):

    if sum(ans_list[i::i+1]) % 2 == num_list[i]:
        ans_list[i] = 0
    else:
        ans_list[i] = 1

for i in range(n):
    if ans_list[i] == 1:
        print(i+1)

Submission status: Wrong Answer

Solution code:
#素数判定
N=int(input())
A=[int(i) for i in input().split()]
n=1

if A[0]==0:
	if A.count("1")==0:
		print("0")
	else:
		print("-1")
else:
	if A.count(1)>2:print("-1")
	elif A.count(1)==1:
		print("1")
		print("1",end=" ")
		for n in range(N-1):
			print("0",end=" ")
	else:
		A[0]=int("0")
		p=A.index(1)+1
		while True:
			n+=1
	
			if p//2+1==n:
				print("2")
				for i in range(N):
					if i==p-1 or i==0:
						print(1,end=" ")
					else:
						print(0,end=" ")
				break
			if p%n==0:
				print("-1")
				break

Submission status: Wrong Answer

Solution code:
#素数判定
N=int(input())
A=[int(i) for i in input().split()]
n=1

if A[0]==0:
	if A.count("1")==0:
		print("0")
	else:
		print("-1")
else:
	if A.count(1)>2:print("-1")
	elif A.count(1)==1:
		print("1")
		print("1")
	else:
		A[0]=int("0")
		p=A.index(1)+1
		while True:
			n+=1
	
			if p//2+1==n:
				print("2")
				for i in range(N):
					if i==p-1 or i==0:
						print(1,end=" ")
					else:
						print(0,end=" ")
				break
			if p%n==0:
				print("-1")
				break

Submission status: Wrong Answer

Solution code:
#素数判定
N=int(input())
A=[int(i) for i in input().split()]
n=1

if A[0]==0:
	if A.count("1")==0:
		print("0")
	else:
		print("-1")
else:
	if A.count(1)>2:print("-1")
	elif A.count(1)==1:
		print("1")
		print("1")
	else:
		A[0]=int("0")
		p=A.index(1)+1
		while True:
			n+=1
	
			if p//2+1==n:
				print("2")
				for i in range(N):
					if i==p or i==0:
						print(1,end=" ")
					else:
						print(0,end=" ")
				break
			if p%n==0:
				print("-1")
				break

Submission status: Wrong Answer

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

j = 0
while i>0:
    sum1=0
    j = i + i
    while j<=N:
        sum1 += B[j-1]
        sum1=(sum1+2)%2
        j=j+i
    B[i-1]+=(A[i-1]+sum1)
    B[i-1]=(B[i-1]+2)%2
    i=i-1
count=0
for s in B:
  if s == 1 :
    count+=1
print(count)
for s in B:
  if s==1:
    print((B.index(s)+1),end=" ")

Submission status: Wrong Answer

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

j = 0
while i>0:
    sum1=0
    j = i + i
    while j<=N:
        sum1 += B[j-1]
        sum1=(sum1+2)%2
        j=j+i
    B[i-1]+=(A[i-1]+sum1)
    B[i-1]=(B[i-1]+2)%2
    i=i-1
count=0
for s in B:
  if s == 1 :
    count+=1
print(count)
for s in B:
  if s==1:
    print(s,end=" ")

Submission status: Wrong Answer

Solution code:
#素数判定
N=int(input())
A=[int(i) for i in input().split()]
n=1

if A[0]==0:
	if A.count("1")==0:
		print("0")
	else:
		print("-1")
else:
	if A.count(1)>2:print("-1")
	elif A.count(1)==1:
		print("1")
		print("1")
	else:
		A[0]=int("0")
		p=A.index(1)+1
		while True:
			n+=1
			if p%n==0:
				print("-1")
				break
			
			if p//2+1==n:
				print("2")
				for i in range(N):
					if i==p or i==1:
						print(1,end=" ")
					else:
						print(0,end=" ")
				break

Submission status: Wrong Answer

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

j = 0
while i>0:
    sum1=0
    j = i + i
    while j<=N:
        sum1 += B[j-1]
        sum1 %=2
        j=j+i
    B[i-1]+=(A[i-1]+sum1)
    B[i-1]%=2
    i=i-1
count=0
for s in B:
  if s == 1 :
    count+=1
print(count)
for s in B:
  if s==1:
    print(s,end=" ")

Submission status: Wrong Answer

Solution code:
#素数判定
N=int(input())
A=[int(i) for i in input().split()]
n=1

if A[0]==0:
	if A.count("1")==0:
		print("0")
	else:
		print("-1")
else:
	if A.count(1)>2:print("-1")
	elif A.count(1)==1:
		print("1")
		print("1")
	else:
		A[0]=int("0")
		p=A.index(1)+1
		while True:
			n+=1
			if p%n==0:
				print("-1awgnsp",p,n,p%n)
				break
			
			if p//2+1==n:
				print("2")
				for i in range(N):
					if i==p or i==1:
						print(1,end=" ")
					else:
						print(0,end=" ")
				break

Submission status: Wrong Answer

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

j = 0
while i>0:
    sum1=0
    j = i + i
    while j<=N:
        sum1 += B[j-1]
        j=j+i
    B[i-1]+=(((A[i-1]+sum1)+2)%2)
    i=i-1
count=0
for s in B:
  if s == 1 :
    count+=1
print(count)
for s in B:
  if s==1:
    print(s,end=" ")

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
B = [0 for i in range(N)]
i = N
while i>0:
    sum1=0
    j = i + i
    while j<=N:
        sum1 += B[j-1]
        j=j+i
    B[i-1]+=(A[i-1]+sum1)
    i=i-1
count=0
for s in B:
  if s == 1 :
    count+=1
print(count)
for s in B:
  if s==1:
    print(s,end=" ")

Submission status: Wrong Answer

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

j = 0
while i>0:
    sum1=0
    j = i + i
    while j<=N:
        sum1 += B[j-1]
        j=j+i
    B[i-1]+=(A[i-1]+sum1)
    i=i-1
count=0
for s in B:
  if s == 1 :
    count+=1
print(count)
for s in B:
  if s==1:
    print(s,end=" ")

Submission status: Wrong Answer

Solution code:
n = int(input())
A = list(map(int, input().split()))
ans = [0]*(n+1) 
output = []
cnt = 0

end = n+1
length = 0
for i in range(2, -(-n//2) + 1):
  begin = -(-n//i) 
  if end - begin != 0:
    for j in range(begin, end):
      ans[j] = A[j-1]
      #print("begin,end", begin, end, j)
      if i > 2:
        for k in range(2, i):
          #print("----")
          #print("j*k", j*k)
          ans[j] = (2 + ans[j] - ans[j*k])%2
      if ans[j] == 1:
        cnt += 1
        output.append(j)
  end = begin
  
ans[1] = (A[0] - sum(ans[1:]))%2
if ans[1] == 1:
  cnt += 1
  output.append(1)

if cnt == 0:
  print(0)
else:
  print(cnt)
  print(*output)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
for i in range(N, 1, -1):
  ans = A[i-1]
  for o in range(1, int(i ** 0.5) + 1):
    if i%o == 0:
      A[o-1]  = (A[o-1] + ans)%2
      if o != i//o:
        A[(i//o) - 1] = (A[(i//o) - 1] + ans)%2
 
print(A.count(1))
ans = [str(q) for q, w in zip(range(1, N+1), A) if w == 1]
print(" ".join(ans))

Submission status: Wrong Answer

Solution code:
import math

N=int(input())
a=list(map(int, input().split()))
H=math.floor(N / 2)
B=a[:]

for i in range(H-1,-1,-1):
    s = 0
    j = i
    j+=(i+1)
    while j < N:
        s+=B[j]
        j+=(i+1)
    m = s % 2
    B[i] = a[i] ^ m

print(B)
ans = [i + 1 for i, x in enumerate(B) if x == 1]
l = len(ans)
print(l)
if (l > 0):
    print(*ans)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!

N = int(input())
A = list(map(int, input().split(" ")))

box = [0]*N

for i in range(N//2+1, N):
    #print(i)
    if A[i] == 1:
        box[i] = 1

def func_k(start, k):
#ｋの倍数の箱に入ってるボールの個数の偶奇を返す。startの箱にボールを入れる入れないかを決める決定的根拠になる。
    start += 1
    k += 1
    SUM = 0
    j = start + k
    while j < N:
        SUM += box[j]
        j += k
    return SUM%2
    
for i in range(N//2, -1, -1):
    #print(i)
    if func_k(i,i) != A[i]:
        box[i] = 1


print(box.count(1))
for k in range(N):
    if box[k] == 1:
        print(i+1,end=" ")

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
A_0 = A[0]
for i in range(N, 0, -1):
    ans = A[i-1]
    for o in range(1, int(i ** 0.5) + 1):
        if i%o == 0:
            A[o-1]  = (A[o-1] + ans)%2
            if o != i//o:
                A[(i//o) - 1] = (A[(i//o) - 1] + ans)%2
 
print(A.count(1))
ans = [str(q) for q, w in zip(range(1, N+1), A) if w == 1]
print(" ".join(ans))

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
for i in range(N//2+1, 0, -1):
  sum = 0
  for o in range(1, (N//i)+1):
    sum += A[i*o-1]
  A[i-1] = sum%2
  
print(A.count(1))
ans = [str(q) for q,w in zip(range(N), A) if w == 1]
print(" ".join(ans))

Submission status: Wrong Answer

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

hako = [0] * (N+1)

for i in range(1,N+1)[::-1]:
    if i > N / 2:
        if a[i-1] == 1:
            hako[i] = a[i-1]
    else:
        count = 0
        for j in range(i+1,N+1,i):
            if j%i == 0:
                count += a[j-1]

        if count % 2 == a[i-1]:
            hako[i] = 0
        else:
            hako[i] = 1

print(sum(hako))

if sum(hako):
    ans = []
    for i, bin in enumerate(hako):
        if bin:
            ans.append(i)
    print(*ans)

Submission status: Wrong Answer

Solution code:
import math
from collections import deque

N=int(input())
a=list(map(int, input().split()))
B=deque()

for i in range(N-1,-1,-1):
    s = 0
    j = i
    j+=(i+1)
    while j < N:
        s+=a[j]
        j+=(i+1)
    m = s % 2
    if (a[i] == 0 and m == 0):
        b = 0
    elif (a[i] == 0 and m == 1):
        b = 1
    elif (a[i] == 1 and m == 0):
        b = 1
    elif (a[i] == 1 and m == 1):
        b = 0
    B.appendleft(b)

ans = [i + 1 for i, x in enumerate(B) if x == 1]
l = len(ans)
print(l)
if (l > 0):
    print(*ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
n = int(input())
a = np.array(list(map(int, input().strip().split())))
b = [0] * (n+1)
for i in range(n):
    b[i+1] = a[i]

#print(b)

#print('p',n//2)
for i in reversed(range(1,n//2 + 1)):
    j = 2
    b_sum = 0
    #print(i)
    while i * j <= n:
        #print(i,j)
        b_sum += b[i*j]
        j += 1
    if (b_sum % 2) == a[i-1]:
        b[i] = 0
    else:
        b[i] = 1

#print(b)

s = sum(b)

print(s)
if s > 0:
    sl = ''
    for i in range(len(b)):
        if b[i] == 1:
            sl += '1' + ' '

    print(sl[:-1])

Submission status: Wrong Answer

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

hako = [0] * (N+1)

for i in range(1,N+1)[::-1]:
    if i > N / 2:
        if a[i-1] == 1:
            hako[i] = a[i-1]
    else:
        count = 0
        for j in range(i+2,N+1,i+1):
            if j%i == 0:
                count += a[j-1]

        if count % 2 == a[i-1]:
            hako[i] = 0
        else:
            hako[i] = 1

print(sum(hako))

if sum(hako):
    ans = []
    for i, bin in enumerate(hako):
        if bin:
            ans.append(i)
    print(*ans)

Submission status: Wrong Answer

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

result = [0] * N
for i in range(N):
    if A_list[N - i - 1] == 1 and (N - i) * 2 >= N:
        result[N - i - 1] = 1
    if A_list[N - i - 1] == 0 and (N - i) * 2 >= N:
        result[N - i - 1] = 0
    if A_list[N - i - 1] == 1 and (N - i) * 2 < N:
        tmp_sum = 0
        for r in range(N - i - 1, N, N - i):
            tmp_sum += result[r]
        if tmp_sum % 2 == 0:
            result[N - i - 1] = 1
        if tmp_sum % 2 == 1:
            result[N - i - 1] = 0
    if A_list[N - i - 1] == 0 and (N - i) * 2 < N:
        tmp_sum = 0
        for r in range(N - i - 1, N, N - i):
            tmp_sum += result[r]
        if tmp_sum % 2 == 0:
            result[N - i - 1] = 0
        if tmp_sum % 2 == 1:
            result[N - i - 1] = 1

print(sum(result))
for i, r in enumerate(result):
    if r == 1:
        print(i + 1)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
A_0 = A[0]
for i in range(N, 0, -1):
    ans = A[i-1]
    for o in range(1, int(i ** 0.5) + 1):
        if i%o == 0:
            A[o-1]  = (A[o-1] + ans)//2
            if o != i//o:
                A[(i//o) - 1] = (A[(i//o) - 1] + ans)//2

print(A.count(1))
[print(q) for q, w in zip(range(1, N+1), A) if w == 1]

Submission status: Wrong Answer

Solution code:
"""
from collections import defaultdict
from collections import deque

def prime(N):
    se = [0,0,1]+[1]*(N-2)
    n = 2
    while n ** 2 <= N:
        if se[n]:
            nn = 2*n
            while nn <= N:
                se[nn] = 0
                nn += n
        n += 1

    return [x for x in range(0,N+1) if se[x]]
"""
N = int(input())
A = list(map(int,input().split()))

# N = 1のときはコーナーケース！

if N == 1:
    if A[0] == 1:
        print(1)
        print(1)
    else:
        print(0)
    exit()

#deq = deque()

"""
pr = prime(N)

deq = deque(pr)
deq.appendleft(1)

cnt = len(deq)

d = [0]*(N+1)
d[1] = -1
for p in pr:
    d[p] = -1

B = pr
while cnt < N:
    C = []
    for num in B:
        if num * 2 > N:
            break
        for p in pr:
            if num * p > N:
                break
            aaa = num * p
            if d[aaa] <= 0:
                d[aaa] = p
                deq.append(aaa)
                C.append(aaa)
                cnt += 1
    B = sorted(C)
"""
B = [0]*N

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

a = sum(B)
print(a)
for _ in range(a):
    print(1)

Submission status: Wrong Answer

Solution code:
import numpy as np
n = int(input())
a = np.array(list(map(int, input().strip().split())))
b = [0] * (n+1)
for i in range(n):
    b[i+1] = a[i]

#print(b)

#print('p',n//2)
for i in reversed(range(1,n//2 + 1)):
    j = 2
    b_sum = 0
    #print(i)
    while i * j <= n:
        #print(i,j)
        b_sum += b[i*j]
        j += 1
    if (b_sum % 2) == a[i-1]:
        b[i] = 0
    else:
        b[i] = 1

#print(b)

s = sum(b)

print(s)
if s > 0:
    for i in range(s):
        if i == s - 1:
            print(1)
        else:
            print(1,end=' ')

Submission status: Wrong Answer

Solution code:
import numpy as np
n = int(input())
a = np.array(list(map(int, input().strip().split())))
b = [0] * (n+1)
for i in range(n):
    b[i+1] = a[i]

#print(b)
count = 0

#print('p',n//2)
for i in reversed(range(1,n//2 + 1)):
    j = 2
    b_sum = 0
    #print(i)
    while i * j <= n:
        #print(i,j)
        b_sum += b[i*j]
        j += 1
    if (b_sum % 2) == a[i-1]:
        b[i] = 0
    else:
        b[i] = 1

#print(b)

s = sum(b)

if s == 0:
    print(0)
else:
    for i in range(s):
        if i == s - 1:
            print(1)
        else:
            print(1,end=' ')