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:
N = int(input())
A = list(map(int,input().split()))
ball = [0] * N

def divisors(n):
  for i in range(1, int(n ** 0.5) + 1):
    if n % i == 0:
      ball[i - 1] += 1
  if n != 1:
    ball[n - 1] += 1

for i in range(N - 1,-1,-1):
  if A[i] != (ball[i] % 2):
    divisors(i + 1)

if sum(ball) == 0:
  print(0)
else:
  M = sum(ball)
  ball = [i for i in ball if i >= 1]
  print(M)
  print(*ball)

Submission status: Wrong Answer

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

def divisors(n):
  for i in range(1, int(n ** 0.5) + 1):
    if n % i == 0:
      ball[i - 1] += 1

for i in range(N - 1,-1,-1):
  if A[i] != (ball[i] % 2):
    divisors(A[i])

if sum(ball) == 0:
  print(0)
else:
  M = sum(ball)
  ball = [i for i in ball if i == 1]
  print(M)
  print(*ball)

Submission status: Wrong Answer

Solution code:
# 後ろから見ていく
# N番目の箱の倍数は１つしかないため、確定できる。
# 後ろ半分は倍数の箱を持たない
# 後ろから
# これの繰り返し

n=int(input())
a=list(map(int,input().split()))
h=n//2

b=[0]*h+a[h:]
for i in range(h,-1,-1):
  # 自分を除く自分の倍数を数える
  jsum=0
  for j in range((i+1)*2-1,len(b),i+1):
    jsum^=a[j]
  b[i]=a[i]^jsum
print(sum(b))
for i in range(n):
  if b[i]:
    print(i+1)

Submission status: Wrong Answer

Solution code:
# 後ろから見ていく
# N番目の箱の倍数は１つしかないため、確定できる。
# 後ろ半分は倍数の箱を持たない
# 後ろから
# これの繰り返し

n=int(input())
a=list(map(int,input().split()))
h=n//2

b=[0]*h+a[h:]
for i in range(h,-1,-1):
  # 自分を除く自分の倍数を数える
  jsum=0
  for j in range((i+1)*2,len(b),i+1):
    jsum^=a[j]
  b[i]=a[i]^jsum
print(sum(b))
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()))

balls = [0] * n

def get_b(num):
    cnt=0
    now=num
    while True:
        cnt+=balls[now-1]
        now+=num
        if now >= n:
            break
    return cnt

for i in range(n,0,-1):
    now_cnt=get_b(i)
    if now_cnt%2 != a[i-1]:
        balls[i-1]=1

print(sum(balls))

for i in range(n):
    if balls[i] != 0:
        print(i+1,end=" ")

Submission status: Wrong Answer

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

for i in range(N//2 + 1, N):
    if a[i] == 1:
        b.add(i)

for i in range(N//2, 0, -1):
    k, temp = 2, 0
    while k * i < N:
        if k * i in b:
            temp += 1
        k += 1
    if temp % 2 != a[i]:
        b.add(i)

if len(b) > 0:
    print(len(b))
    print(' '.join(list(map(str, sorted(list(b))))))
else:
    print(0)

Submission status: Wrong Answer

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

for i in range(N//2, N):
    if a[i] == 1:
        b.add(i)

for i in range(N//2 - 1, 0, -1):
    k, temp = 2, 0
    while k * i < N:
        if k * i in b:
            temp += 1
        k += 1
    if temp % 2 != a[i]:
        b.add(i)

if len(b) > 0:
    print(len(b))
    print(' '.join(list(map(str, sorted(list(b))))))
else:
    print(0)

Submission status: Wrong Answer

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

for i in range(N//2, N):
    if a[i] == 1:
        b.add(i)

for i in range(N//2 - 1, 0, -1):
    k, temp = 2, 0
    while k * i < N:
        if k * i in b:
            temp += 1
        k += 1
    if temp % 2 != a[i]:
        b.add(i)

if len(b) > 0:
    print(len(b))
    print(''.join(list(map(str, sorted(list(b))))))
else:
    print(0)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
N = int(input())
A = list(map(int, input().split()))
A.reverse()
B = [0 for i in range(N+1)]
for i in range(1, N+1):
    tmp = 0
    for j in range(0, i+1, i):
        tmp += B[j]
    if A[i-1] % 2 != tmp % 2:
        B[i-1] = 1
B.reverse()
ans = []
M = sum(B)
for i in range(N):
    if B[i] == 1:
        ans.append(i)
print(M)
if M == 0:
  exit()
print(*ans)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
N = int(input())
A = list(map(int, input().split()))
A.reverse()
B = [0 for i in range(N)]
for i in range(N):
    tmp = 0
    for j in range(0, i+1, i+1):
        tmp += B[j]
    if A[i] % 2 != tmp % 2:
        B[i] = 1
B.reverse()
ans = []
M = sum(B)
for i in range(N):
    if B[i] == 1:
        ans.append(i+1)
print(M)
print(*ans)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
N = int(input())
A = list(map(int, input().split()))
A.reverse()
B = [0 for i in range(N)]
for i in range(N):
    tmp = 0
    for j in range(0, i, i+1):
        tmp += B[j]
    if A[i] % 2 != tmp % 2:
        B[i] = 1
B.reverse()
ans = []
M = sum(B)
for i in range(N):
    if B[i] == 1:
        ans.append(i+1)
print(M)
print(*ans)

Submission status: Wrong Answer

Solution code:
import sys

n, *a = map(int, sys.stdin.read().split())
a = [None] + a

def main():
    res = [0] * (n + 1)
    chosen = []
    for i in range(n, 0, -1):
        res[i] = sum(res[i*2:n+1:i]) & 1
        if res[i] ^ a[i]:
            res[i] ^= 1
            chosen.append(i)

    if chosen:
        m = len(chosen)
        return [m], chosen[::-1]
    else:
        return [[0]]

if __name__ == '__main__':
    ans = main()
    for a in ans:
        print(*a, sep=' ')

Submission status: Wrong Answer

Solution code:
import sys
from math import floor, sqrt

n, *a = map(int, sys.stdin.read().split())
a = [None] + a

def factorize(n):
    res = []
    for i in range(1, floor(sqrt(n)) + 1):
        if not n % i:
            res.append(i)
            res.append(n // i)
    return sorted(res)

def main():
    res = [0] * (n + 1)
    chosen = []
    for i in range(n, 0, -1):
        if a[i] ^ res[i]:
            chosen.append(i)
            facts = factorize(i)
            for j in facts:
                res[j] ^= 1

    if chosen:
        m = len(chosen)
        return [m], chosen[::-1]
    else:
        return [[0]]

if __name__ == '__main__':
    ans = main()
    for a in ans:
        print(*a, sep=' ')

Submission status: Wrong Answer

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

t=((n+1)+2-1)//2

ans=[-1]+[0 for i in range(n)]
ans[t:]=a[t:]

#print(a)
#print(ans)

for i in range(t-1,0,-1):
 t_sum=sum(ans[i+i::i])
# print(i,a[i],t_sum)
 if a[i]%2==t_sum%2:
  ans[i]=0
 else:
  ans[i]=1

#print(ans)

m=ans.count(1)
ans_l=[]
for i in range(n+1):
 if ans[i]==1:
  ans_l.append(i)
#print(m)
if ans_l:
 print(*ans_l)

Submission status: Wrong Answer

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

t=(n+2-1)//2

ans=[-1]+[0 for i in range(n)]
ans[t:]=a[t:]

#print(a)
#print(ans)

for i in range(t-1,0,-1):
 t_sum=sum(a[i+i::i])
# print(i,t_sum)
 if a[i]%2==t_sum%2:
  ans[i]=0
 else:
  ans[i]=1

#print(ans)

m=ans.count(1)
ans_l=[]
for i in range(n+1):
 if ans[i]==1:
  ans_l.append(i)
print(m)
if ans_l:
 print(*ans_l)

Submission status: Wrong Answer

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

t=(n+2-1)//2

ans=[-1]+[0 for i in range(n)]
ans[t:]=a[t:]

#print(a)
#print(ans)

for i in range(t-1,0,-1):
 t_sum=sum(a[i+i::i])
# print(i,t_sum)
 if a[i]%2==t_sum%2:
  ans[i]=0
 else:
  ans[i]=1

#print(ans)

m=ans.count(1)
ans_l=[]
for i in range(n):
 if ans[i]==1:
  ans_l.append(i)
print(m)
if ans_l:
 print(*ans_l)

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int,input().split()))
B=[0]*N
ret1=0
ret2=''
for i in range(N, 0, -1):
  if sum(B[2*i:N:i]) ^ A[i-1]:
    B[i-1]=1
    ret1+=1
    ret2=str(i)+' '+ret2
print(ret1)
print(ret2)

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int,input().split()))
B=[0]*N
ret1=0
ret2=''
for i in range(N, 0, -1):
  tot=0
  j=i*2
  while j<N:
    tot+=B[j-1]
    j+=i
  if tot%2 ^ A[i-1]:
    B[i-1]=1
    ret1+=1
    ret2=str(i)+' '+ret2
print(ret1)
print(ret2)

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int,input().split()))
B=['0']*N
ret1=0
ret2=''
for i in range(N//2-1,N):
  B[i]=str(A[i])
for i in range(N//2, 0, -1):
  Bit='0'*i+('0'*(i-1)+'1')*(N//i)
  Bit=int(Bit[:N], 2)
  BBit=int(''.join(B), 2)
  if bin(BBit & Bit).count('1')%2 ^ A[i-1]:
    ret1+=1
    B[i-1]='1'
    ret2=str(i)+' '+ret2
print(ret1)
print(ret2)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10 ** 6)


def input():
    return sys.stdin.readline()[:-1]


def main():
    N = int(input())
    a = [-1]+list(map(int, input().split()))
    b = [0] * (N+1)
    for i in reversed(range(1,N+1)):
        total = 0
        for j in range(i,N+1):
            if i%j==0:
                total += b[j]
        if a[i] != (total%2):
            b[i] = 1
    print(*b[1:])

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys
n = int(input())
a = list(map(int, input().split()))
ans = [0] * (n+1)
ans_index = set([])
for i in reversed(range(1, n)):
    sum_i = sum(ans[i * 2:n + 1:i])
    if a[i-1] == (sum_i + 1) % 2:
        ans[i] = 1
        ans_index.add(i)
    elif a[i-1] == sum_i % 2:
        ans[i] = 0
    else:
        print(-1)
        sys.exit()
print(sum(ans))
if ans_index:
    print(*ans_index)

Submission status: Wrong Answer

Solution code:
import sys
n = int(input())
a = list(map(int, input().split()))
ans = [0] * (n+1)
ans_index = set([])
for i in reversed(range(1, n)):
    sum_i = sum(ans[i * 2:n:i])
    if a[i-1] == (sum_i + 1) % 2:
        ans[i] = 1
        ans_index.add(i)
    elif a[i-1] == sum_i % 2:
        ans[i] = 0
    else:
        print(-1)
        sys.exit()
print(sum(ans))
if ans_index:
    print(*ans_index)

Submission status: Wrong Answer

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

def sumN(n,N,f):
	total = 0
	i = n
	while i < N:
		total += f[i]
		i += n+1

	if total % 2:
		return 1
	else:
		return 0

def main():
	N = int(input())
	a = list(map(int,input().split()))
	ball = []
	ballNum = 0
	f = [0]*N

	for i in reversed(range(1,N)):
		if (sum(f[0::i+1])%2) != (a[i] % 2):
			f[i] = 1
			ball.append(i+1)
			ballNum +=1

	if (sum(f) % 2) != (a[0] % 2):
		f[0] = 1
		ball.append(1)
		ballNum +=1

	print(ballNum)
	print(*ball)

if __name__ == "__main__":
	main()

Submission status: Wrong Answer

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

def sumN(n,N,f):
	total = 0
	i = n
	while i < N:
		total += f[i]
		i += n+1

	if total % 2:
		return 1
	else:
		return 0

def main():
	N = int(input())
	a = list(map(int,input().split()))
	ball = []
	ballNum = 0
	f = [0]*N
	
	for i in reversed(range(1,N)):
		if sum(f[0::i+1]) != (a[i] % 2):
			f[i] = 1
			ball.append(i+1)
			ballNum +=1

	if (sum(f) % 2) != (a[0] % 2):
		f[0] = 1
		ball.append(1)
		ballNum +=1

	print(ballNum)
	print(*ball)

if __name__ == "__main__":
	main()

Submission status: Wrong Answer

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

def sumN(n,N,f):
	total = 0
	i = n
	while i < N:
		total += f[i]
		i += n+1

	if total % 2:
		return 1
	else:
		return 0

def main():
	N = int(input())
	a = list(map(int,input().split()))
	ball = []
	ballNum = 0
	f = [0]*N

	for i in reversed(range(1,N)):
		if sum(f[i:i]) != (a[i] % 2):
			f[i] = 1
			ball.append(i+1)
			ballNum +=1

	if (sum(f) % 2) != (a[0] % 2):
		f[0] = 1
		ball.append(1)
		ballNum +=1

	print(ballNum)
	print(*ball)

if __name__ == "__main__":
	main()

Submission status: Wrong Answer

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

def sumN(n,N,f):
	total = 0
	i = n
	while i < N:
		total += f[i]
		i += n+1

	if total % 2:
		return 1
	else:
		return 0

def main():
	N = int(input())
	a = list(map(int,input().split()))
	ball = []
	ballNum = 0
	f = [0]*N

	for i in reversed(range(1,N)):
		if sum(f[i:i+1]) != (a[i] % 2):
			f[i] = 1
			ball.append(i+1)
			ballNum +=1

	if (sum(f) % 2) != (a[0] % 2):
		f[0] = 1
		ball.append(1)
		ballNum +=1

	print(ballNum)
	print(*ball)

if __name__ == "__main__":
	main()

Submission status: Wrong Answer

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

def main():
	N = int(input())
	a = list(map(int,input().split()))
	ball = []
	ballNum = 0
	f = [0]*N

	for i in reversed(range(1,N)):
		if (sum(f[0::i+1]) % 2) != (a[i] % 2):
			f[i] = 1
			ball.append(i+1)
			ballNum +=1

	if (sum(f) % 2) != (a[0] % 2):
		f[0] = 1
		ball.append(1)
		ballNum +=1

	print(ballNum)
	print(*ball)

if __name__ == "__main__":
	main()

Submission status: Wrong Answer

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

def main():
	N = int(input())
	a = list(map(int,input().split()))
	ball = []
	ballNum = 0
	f = [0]*N

	for i in reversed(range(N)):
		k = i+1
		if (sum(f[0::k]) % 2) != (a[i] % 2):
			f[i] = 1
			ball.append(i+1)
			ballNum +=1

	print(ballNum)
	print(*ball)

if __name__ == "__main__":
	main()

Submission status: Wrong Answer

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

def main():
	N = int(input())
	a = list(map(int,input().split()))
	ball = []
	ballNum = 0
	f = [0]*N

	for i in reversed(range(N)):
		if (sum(f[0::i+1]) % 2) != (a[i] % 2):
			f[i] = 1
			ball.append(i+1)
			ballNum +=1

	print(ballNum)
	print(*ball)

if __name__ == "__main__":
	main()

Submission status: Wrong Answer

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

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

    B = [[] for i in range(N+1)]
    B[0] = 0

    for i in range(N, 0, -1):
        if 2*i > N:
            B[i] = A[i]
        else:
            B[i] = sum(A[i::i])%2

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


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

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

    B = [[] for i in range(N+1)]
    B[0] = 0

    for i in range(N, 0, -1):
        if 2*i > N:
            B[i] = A[i]
        else:
            B[i] = (A[i] + A[i*2])%2

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


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
N = int(input())
*b, = map(int, input().split())
ans = []

for i in range(N)[::-1]:
    n = i+1
    if b[i]:
        ans.append(n)
        for j in range(1, int(n**0.5)+2):
            if n%j==0:
                b[j-1] ^= 1
                if j!=n//j:
                    b[n//j-1] ^= 1

M = len(ans)
print(M)
if ans:
    print(*ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
*b, = map(int, input().split())
ans = []

for i in range(N)[::-1]:
    n = i+1
    if b[i]:
        ans.append(n)
        
        tmp = 1
        while tmp*tmp <= n:
            if n % tmp == 0:
                b[tmp-1] ^= 1
                if tmp != n//tmp:
                    b[n//tmp-1] ^= 1
            tmp += 1

M = sum(ans)
print(M)
if ans:
    print(*ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
*b, = map(int, input().split())
ans = []

for i in range(N)[::-1]:
    n = i+1
    if b[i]:
        ans.append(n)
        for j in range(1, int(n**0.5)+2):
            if n%j==0:
                b[j-1] ^= 1
                if j!=n//j:
                    b[n//j-1] ^= 1

M = sum(ans)
print(M)
if ans:
    print(*ans)

Submission status: Wrong Answer

Solution code:
N = int(input())

*b, = map(int, input().split())
ans = []

for i in range(N)[::-1]:
    n = i+1
    if b[i]:
        ans.append(n)
        for j in range(1, int(n**0.5)+1):
            if n%j==0:
                b[j-1] ^= 1
                if j!=n//j:
                    b[n//j-1] ^= 1

M = sum(ans)
print(M)
if ans:
    print(*ans)

Submission status: Wrong Answer

Solution code:
N = int(input())

*b, = map(int, input().split())
ans = []

for i in range(N)[::-1]:
    n = i+1
    buf = n

    if b[i]:
        ans.append(n)
        b[n-1] ^= 1

        for j in range(2, int(n**0.5)+1):
            if n==1:break
            while n%j==0:
                n //= j
                b[n-1] ^= 1
                if n!=buf//n:
                    b[buf//n-1] ^= 1
        b[0] ^= 1

M = sum(ans)
print(M)
if ans:
    print(*ans)

Submission status: Wrong Answer

Solution code:
N = int(input())

*b, = map(int, input().split())
ans = []

for i in range(N)[::-1]:
    n = i+1
    buf = n

    if b[i]:
        ans.append(n)
        b[n-1] ^= 1

        for j in range(2, int(n**0.5)+1):
            if n==1:break
            while n%j==0:
                n //= j
                b[n-1] ^= 1
                b[buf//n-1] ^= 1
        b[0] ^= 1

M = sum(ans)
print(M)
if ans:
    print(*ans)

Submission status: Wrong Answer

Solution code:
N = int(input())

*b, = map(int, input().split())
ans = []

for i in range(N)[::-1]:
    n = i+1

    if b[i]:
        ans.append(n)
        b[n-1] ^= 1

        for j in range(2, int(n**0.5)+1):
            if n==1:break
            while n%j==0:
                n //= j
                b[n-1] ^= 1 
        b[0] ^= 1

M = sum(ans)
print(M)
if ans:
    print(*ans)

Submission status: Wrong Answer

Solution code:
N = int(input())

*b, = map(int, input().split())
ans = []

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

        for j in range(2, int(n**0.5)+1):
            if n==1:break
            while n%j==0:
                b[n-1] ^= 1
                n//=j
        b[0] ^= 1

M = sum(ans)
print(M)
if ans:
    print(*ans)

Submission status: Wrong Answer

Solution code:
N = int(input())

*b, = map(int, input().split())
ans = []

for i in range(N)[::-1]:
    n = i+1
    if b[i]:
        ans.append(n)
        b[n-1] ^= 1
        
        for i in range(2, int(n**0.5)+1):
            if n==1:break
            while n%i==0:
                b[n-1] ^= 1
                n//=i
        b[0] ^= 1

M = sum(ans)
print(M)
if ans:
    print(*ans)

Submission status: Wrong Answer

Solution code:
N = int(input())

*b, = map(int, input().split())
ans = []

for i in range(N)[::-1]:
    n = i+1
    if b[i]:
        ans.append(n)
        for i in range(2, int(n**0.5)+1):
            if n==1:break
            while n%i==0:
                b[n-1] ^= 1
                n//=i
        b[0] ^= 1

M = sum(ans)
print(M)
if ans:
    print(*ans)

Submission status: Wrong Answer

Solution code:
N = int(input())

*b, = map(int, input().split())
ans = [0]*(N+1)

for i in range(N)[::-1]:
    n = i+1
    t = b[i]

    for i in range(2, int(n**0.5)+1):
        if n==1:break
        while n%i==0:
            ans[n] ^= t
            n//=i
    ans[1] ^= t

M = sum(ans)
print(M)

if M!=0:
    print(*(i for i,j in enumerate(ans) if j))

Submission status: Wrong Answer

Solution code:
N = int(input())

*b, = map(int, input().split())
ans = [0]*(N+1)

for i in range(N)[::-1]:
    n = i+1
    if b[i]==ans[n]:
        continue
    for i in range(2, int(n**0.5)+1):
        if n==1:break
        while n%i==0:
            ans[n] ^= 1
            n//=i
    ans[1] ^= 1

M = sum(ans)
print(M)

if M!=0:
    print(*(i for i,j in enumerate(ans) if j))

Submission status: Wrong Answer

Solution code:
N = int(input())

*b, = map(int, input().split())
ans = [0]*(N+1)

for i in range(N)[::-1]:
    n = i+1
    if b[i]:
        if b[i]==ans[n]:
            continue
        for i in range(2, int(n**0.5)+1):
            if n==1:break
            while n%i==0:
                ans[n] ^= 1
                n//=i
        ans[1] ^= 1

M = sum(ans)
print(M)

if M!=0:
    print(*(i for i,j in enumerate(ans) if j))

Submission status: Wrong Answer

Solution code:
N = int(input())

*b, = map(int, input().split())
ans = [0]*(N+1)

for i in range(N)[::-1]:
    n = i+1
    if b[i]:
        for i in range(2, int(n**0.5)+1):
            if n==1:break
            while n%i==0:
                ans[n] ^= 1
                n//=i
        ans[1] ^= 1

M = sum(ans)
print(M)

if M!=0:
    print(*(i for i,j in enumerate(ans) if j))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if N==1:
    if a[1]:
        print(1)
        print(1)
    else:
        print(0)
else:
    for i in range(2, N+1)[::-1]:
        for j in range(N):
            if j==0:
                ans[i] = a[i]
            else:
                if a[i] == a[i*2]:
                    ans[i] = 0
                else:
                    ans[i] = 1

            if i%2 or i==2:break
            else: i //= 2

    c = sum([1][2:])%2
    v = a[1]
    if c==v:
        ans[1] = 0
    else:
        ans[1] = 1

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

Submission status: Wrong Answer

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

for i in range(2, N+1)[::-1]:
    for j in range(N):
        if j==0:
            ans[i] = a[i]
        else:
            if a[i] == a[i*2]:
                ans[i] = 0
            else:
                ans[i] = 1

        if i%2:break
        else: i //= 2


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

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()))

cnt_list = [0] * N
M = 0
ans_list = []
for i in range(N-1, -1, -1):
    if A[i] == 1 and cnt_list[i] % 2 == 0:
        M += 1
        ans_list.append(i+1)
        tmp_list = make_divisors(i+1)
        for t in tmp_list:
            cnt_list[t-1] += 1
    elif A[i] == 1 and cnt_list[i] % 2 == 1:
        pass
    elif A[i] == 0 and cnt_list[i] % 2 == 0:
        pass
    else:
        M += 1
        ans_list.append(i+1)
        tmp_list = make_divisors(i+1)
        for t in tmp_list:
            cnt_list[t-1] += 1

if M == 0:
    exit()
print(M)
print(" ".join(map(str, ans_list)))

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()))

cnt_list = [0] * N
M = 0
ans_list = []
for i in range(N-1, -1, -1):
    if A[i] == 1 and cnt_list[i] % 2 == 0:
        M += 1
        ans_list.append(i+1)
        tmp_list = make_divisors(i+1)
        for t in tmp_list:
            cnt_list[t-1] += 1
    elif A[i] == 1 and cnt_list[i] % 2 == 1:
        pass
    elif A[i] == 0 and cnt_list[i] % 2 == 0:
        pass
    else:
        M += 1
        ans_list.append(i+1)
        tmp_list = make_divisors(i+1)
        for t in tmp_list:
            cnt_list[t-1] += 1

if M == 0:
    exit()

print(" ".join(map(str, ans_list)))

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()))

cnt_list = [0] * N

for i in range(N-1, -1, -1):
    if A[i] == 1 and cnt_list[i] % 2 == 0:
        tmp_list = make_divisors(i+1)
        for t in tmp_list:
            cnt_list[t-1] += 1
    elif A[i] == 1 and cnt_list[i] % 2 == 1:
        pass
    elif A[i] == 0 and cnt_list[i] % 2 == 0:
        pass
    else:
        tmp_list = make_divisors(i+1)
        for t in tmp_list:
            cnt_list[t-1] += 1

M = 0
for i in cnt_list:
    if i != 0:
        M += 1
print(M)
if M == 0:
    exit()
ans_list = []
for i in range(len(cnt_list)):
    if cnt_list[i] != 0:
        ans_list.append(i+1)
print(" ".join(map(str, ans_list)))

Submission status: Wrong Answer

Solution code:
import math,itertools,fractions,heapq,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n=I()
  l=LI()

  ans=[0]*n

  ind=n
  for i in range(n):
    sm=0
    for j in range(2,n):
      if ind*j>n:
        break
      else:
        sm+=ans[ind*j-1]
    ans[ind-1]=(l[ind-1]+sm)%2
    ind-=1

  # print(ans)

  _ans=[]
  for i,x in enumerate(ans):
    if x==1:
      _ans.append(i+1)

  ln=len(_ans)
  print(ln)
  if ln!=0:
    print(' '.join([str(x) for x in _ans]))

main()
# print(main())

Submission status: Wrong Answer

Solution code:
import math,itertools,fractions,heapq,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n=I()
  l=LI()

  ans=[0]*n

  ind=n-1
  for i in range(n):
    sm=0
    for j in range(n):
      if ind*j<n:
        break
      else:
        sm+=ans[ind*j]
    ans[i]=(l[i]+sm)%2
    ind-=1

  _ans=[]
  for i,x in enumerate(ans):
    if x==1:
      _ans.append(i+1)

  ln=len(_ans)
  print(ln)
  if ln!=0:
    print(' '.join([str(x) for x in _ans]))

main()
# print(main())

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
b = [0]*n
bon = []
bcnt = [0]*n
for i in range(n):
  ri = n - i - 1
  if bcnt[ri] % 2 != a[ri]:
    if ri != 0:
      bcnt[ri] += 1
    for j in range(int((ri+1)**0.5)):
      # print(j)
      if (ri+1) % (j+1) == 0:
        bcnt[j] += 1
    bon.append(ri+1)
    # print(ri+1, bcnt)
for i in range(n):
  if bcnt[i] % 2 != a[i]:
    print(-1)
    exit()
print(len(bon))
print(*bon)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
b = [0]*n
bon = []
bcnt = [0]*n
for i in range(n):
  ri = n - i - 1
  if bcnt[ri] % 2 != a[ri]:
    if ri != 0:
      bcnt[ri] += 1
    for j in range(int((ri+1)**0.5)+1):
      if (ri+1) % (j+1) == 0:
        bcnt[j] += 1
    bon.append(ri+1)
    # print(ri+1, bcnt)
for i in range(n):
  if bcnt[i] % 2 != a[i]:
    print(-1)
    exit()
print(len(bon))
print(*bon)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int, input().split()))
a.insert(0, 0)
b = [0] * N
M = 0
for i in range(N, 0, -1):
    ball = 0
    for j in range(i + i, N, i):
        ball ^= b[j - 1]
    b[i - 1] = ball ^ a[i]
M = sum(b)
print(M)
for i in range(N):
    if b[i]:
        print(i + 1, end = ' ')

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int , input().split()))
a.insert(0,0)
b = [0] * N
M = 0
for i in range(N, 0, -1):
    ball = 0
    for j in range(i, N, i):
        ball ^= b[j - 1]
    b[i - 1] = ball ^ a[i ]
M = sum(b)
print(M)
for i in range(N):
    if b[i]:
        print(i + 1, end = ' ')

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int , input().split()))
ans = []
M = 0
for i in range(N):
    if a[i]:
        M += 1
        ans.append(i + 1)
print(M)
for b in ans:
    print(b, end = ' ')

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    A = [0] + list(map(int, input().split()))
    B = [0] * (N + 1)
    for i in range(len(A)-1, 0, -1):
        B[i] = A[i]
        j = 2
        while i * j < N:
            B[i] ^= B[i * j]
            j += 1

    ans = []
    for i in range(1,N+1):
        if B[i] == 1:
            ans.append(i)
    print(len(ans))
    print(*ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
from collections import defaultdict, deque
import sys, heapq, bisect, math, itertools, string, queue, copy, time
from fractions import gcd
import numpy as np
sys.setrecursionlimit(10**8)
INF = float('inf')
MOD = 10**9+7
EPS = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())




N = int(input())
alist = list(map(int, input().split()))
ans_list = []

for i in range(N, 0, -1):
    if i > N//2:
        if alist[i-1]:
            ans_list.append(i)
    else:
        if sum(alist[i-1::i])%2 != alist[i-1]:
            ans_list.append(i)
print(len(ans_list))
if len(ans_list)>0:
    print(*ans_list)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict, deque
import sys, heapq, bisect, math, itertools, string, queue, copy, time
from fractions import gcd
import numpy as np
sys.setrecursionlimit(10**8)
INF = float('inf')
MOD = 10**9+7
EPS = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())




N = int(input())
alist = list(map(int, input().split()))
ans_list = []

for i in range(N, 0, -1):
    if i > N//2:
        if alist[i-1]:
            ans_list.append(i)
    else:
        if sum(alist[i-1::i])%2 != alist[i-1]:
            ans_list.append(i)
print(len(ans_list))
print(*ans_list)