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 = list(map(int, input().split()))

b_list = [0 for _ in range(N)]
c_list = []
for i in range(N,0,-1):
  # print(i)
  tmp = sum(b_list[i-1::i]) # i-1 番以降の N の倍数を取り出す
  # print(i, b_list[i-1::i])
  if tmp %2 != a_list[i-1]: # 偶奇が合っているかを確認
    b_list[i-1] = 1
    c_list.append(str(i))
if len(c_list)!=0:
  print(len(c_list))
  print(" ".join(c_list))
else:
  print("-1")

Submission status: Wrong Answer

Solution code:
MOD=1000000007
s = [int(x) if x!="?" else -1 for x in input()]
n=len(s)
count=0
dp=[[0 for j in range(13)] for i in range(n+1)]
dp[0][0]=1
for i in range(n):
  if count%50==0:
    for m in range(13):
      dp[i][m] =dp[i][m]%MOD
  
  for j in range(13):
    #　i+1番目が？のときは０〜９の可能性
    if s[i]==-1:
      count+=1
      for k in range(10):
        dp[i+1][(j*10+k)%13]+=dp[i][j]
        

    #  i+1番目が?じゃないとき
    else:
      dp[i+1][(j*10+s[i])%13]+=dp[i][j]

print(dp[n][5]%MOD)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n=int(input())
l=list(map(int,input().split()))
b=[]
emp=[0]*n
ans=0
for i in range(n)[::-1]:
  c=n//(i+1)
  s=0
  while (c+1)*(i+1)<=n:
    s+=emp[(c+1)*(i+1)-1]
    c+=1
    s%=2
  if l[i]!=s:
    b.append(str(i+1))
    ans+=1
    emp[i]=1
print(ans)
print(" ".join(b))

Submission status: Wrong Answer

Solution code:
N = int(input())
a = [int(x) for x in input().split()]


answer = []
B = 0

for i in range(N):
    L = N // (N-i)
    if L == 1:
        answer.append(a[N-i-1])
    else:
        for j in range(L-1):
            t = (N-i) * j
            B += answer[t]
        B = B % 2
        if B == a[N-i-1]:
            answer.append(0)
        else:
            answer.append(1)
    B = 0


k = 0

if answer == [0]:
    print(0)
else:
    answer.reverse()
    print(answer.count(1))
    J = len(answer)
    for i in range(J):
        if answer[i] == 1:
            print(i+1, end=' ')

Submission status: Wrong Answer

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

for i in range(n,0,-1):
    tmp = sum(b[i-1::i])
    if tmp%2!=a[i-1]:
        b[i-1] = 1
        c.append(str(i))
        
print(len(c))
if len(c)!=0:
    print(*c)
else:
    print('0')

Submission status: Wrong Answer

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

for i in range(n,0,-1):
    tmp = sum(b[i-1::i])
    if tmp%2!=a[i-1]:
        b[i-1] = 1
        c.append(str(i))
        
print(len(c))
if len(c)>0:
    print(*c)
else:
    print('0')

Submission status: Wrong Answer

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

for i in range(n,0,-1):
    tmp = sum(b[i-1::i])
    if tmp%2!=a[i-1]:
        b[i-1] = 1
        c.append(i)
        
print(len(c))
if len(c)>0:
    print(*c)
else:
    print('0')

Submission status: Wrong Answer

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

for i in range(n,0,-1):
    tmp = sum(b[i-1::i])
    if tmp%2!=a[i-1]:
        b[i-1] = 1
        c.append(i)
        
print(len(c))
if len(c)>0:
    print(*c)
else:
  print('-1')

Submission status: Wrong Answer

Solution code:
N = int(input())
a = [int(x) for x in input().split()]


answer = []
B = 0

for i in range(N):
    L = N // (N-i)
    if L == 1:
        answer.append(a[N-i-1])
    else:
        for j in range(L-1):
            t = (N-i) * j
            B += answer[t]
        B = B % 2
        if B == a[N-i-1]:
            answer.append(0)
        else:
            answer.append(1)
    B = 0


k = 0
P = len(answer)
while (answer[0] == 0) and (k < P-1):
    answer.remove(0)
    k += 1

if answer == [0]:
    print(0)
else:
    answer.reverse()
    print(answer.count(1))
    J = len(answer)
    for i in range(J):
        if answer[i] == 1:
            print(i+1, end=' ')

Submission status: Wrong Answer

Solution code:
N = int(input())
a = [int(x) for x in input().split()]


answer = []
B = 0

for i in range(N):
    L = N // (N-i)
    if L == 1:
        answer.append(a[N-i-1])
    else:
        for j in range(L-1):
            t = (N-i) * j
            B += answer[t]
        B = B % 2
        if B == a[N-i-1]:
            answer.append(0)
        else:
            answer.append(1)
    B = 0


k = 0
P = len(answer)
while (answer[0] == 0) and (k < P-1):
    answer.remove(0)
    k += 1

if answer == [0]:
    print(0)
else:
    answer.reverse()
    J = len(answer)
    print(J)
    for i in range(J):
        print(answer[i], end=' ')

Submission status: Wrong Answer

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

if sum(b) != 0:
    print(sum(b))
    ans = []
    for i in range(n):
        if b[i] == 1:
            ans.append(i+1)
    print(" ".join(map(str, ans)))
else:
    print("0")

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):
    count=0
    for j in range(i,n+1,i):
        count+=b[j-1]
    if (count%2)!=a[i-1]:      
        b[i-1]=1
c=[1]*(b.count(1))
if len(c)==0:
    print("0")
else:
    print(len(c))
    print(*c)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n=int(input())
l=list(map(int,input().split()))
b=[]
ans=0
for i in range(n)[::-1]:
  c=n//(i+1)
  s=0
  while (c+1)*(i+1)<=n:
    s+=l[(c+1)*(i+1)-1]
    c+=1
    s%=2
  if l[i]!=s:
    b.append(str(i+1))
    ans+=1
    l[i]=1
print(ans)
print(" ".join(b))

Submission status: Wrong Answer

Solution code:
n=int(input())
l=list(map(int,input().split()))
b=[]
ans=0
for i in range(n)[::-1]:
  c=n//(i+1)
  s=0
  while (c+1)*(i+1)<=n:
    s+=l[(c+1)*(i+1)-1]
    c+=1
    s%=2
  if l[i]!=s:
    b.append(str(i+1))
    ans+=1
print(ans)
print(" ".join(b))

Submission status: Wrong Answer

Solution code:
n=int(input())
l=list(map(int,input().split()))
b=[]
ans=0
for i in range(n)[::-1]:
  c=n//(i+1)
  s=0
  while (c+1)*(i+1)<=n:
    s+=l[(c+1)*(i+1)]
    c+=1
    s%=2
  if l[i]!=s:
    b.append(str(i+1))
    ans+=1
print(ans)
print(" ".join(b))

Submission status: Wrong Answer

Solution code:
import sys, math, itertools, bisect, copy, re
from collections import Counter, deque, defaultdict

# from itertools import accumulate, permutations, combinations, takewhile, compress, cycle
# from functools import reduce
# from math import ceil, floor, log10, log2, factorial
# from pprint import pprint

INF = float('inf')
MOD = 10 ** 9 + 7
EPS = 10 ** -7
sys.setrecursionlimit(1000000)

# N = int(input())
# N,M = [int(x) for x in input().split()]
# V = [[0] * 100 for _ in range(100)]
# A = [int(input()) for _ in range(N)]
# DP = [[0] * 100 for _ in range(100)]
# DP = defaultdict(lambda: float('inf'))


N = int(input())
A = [int(x) for x in input().split()]
A = [0] + A

R = []

dl = [[0] * (N + 1) for _ in range(N + 1)]
for i in range(1, N + 1):
    cnt = 1
    while i * cnt <= N:
        dl[i][i * cnt] = 1
        cnt += 1

for i in range(N, 0, -1):
    if A[i] == 1:
        R.append(i)
        for j in range(i, 0, -1):
            A[j] = (A[j] + 1) % 2

print(" ".join([str(i) for i in R]))

# print(R)

Submission status: Wrong Answer

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

m = 0
b_list = []

for i in range(1, n + 1):
    if a_list[i-1] == 1:
        if (n//i)%2 == 1:
            b_list.append(i)
            m += 1

print(m)
if len(b_list) != 0:
    for b in b_list:
        print(b, end="")
        print(" ", end="")

Submission status: Wrong Answer

Solution code:
def pbox(n,a):
    count = 0
    result = []
    x=[0]*n
    for i in xrange(n,0,-1):
        total = 0
        for j in xrange(i,n,i):
#        print("i %d, b %s" %(i+1,b))
            total += x[j-1]
#        print("a[i] %d, total %d" %(a[i],total))
        if  total % 2 != a[i-1]:
            x[i-1]=1
            result.append(i)
        else:
            pass


    print len(result)
    print ' '.join(map(str,result))

if __name__ == '__main__':
    n = int(raw_input())
    a = map(int,raw_input().split())

    pbox(n,a)

Submission status: Wrong Answer

Solution code:
def pbox(n,a):
    count = 0
    result = []
    for i in xrange(n):
        total = 0
        b = [a[j] for j in xrange(i,n,i+1)]
        total = sum(b)
        if total % 2 == 1 and a[i] == 1:
            result.append(i+1)
        else:
            pass
 
    print len(result)
    print ' '.join(map(str,result))
 
if __name__ == '__main__':
    n = int(raw_input())
    a = map(int,raw_input().split())
 
    pbox(n,a)

Submission status: Wrong Answer

Solution code:
def pbox(n,a):
    count = 0
    result = [0]*n
    for i in xrange(n):
        total = 0
        b = [a[j] for j in xrange(n) if (j+1)%(i+1) == 0]
#        print("i %d, b %s" %(i+1,b))
        total = sum(b)
#        print("a[i] %d, total %d" %(a[i],total))
        if total % 2 == 1 and a[i] % 2 == 1:
            result[i] = i+1
            count += 1
        else:
            result[i] = 0


    print count
    for i in xrange(n):
        print result[i],

if __name__ == '__main__':
    n = int(raw_input())
    a = map(int,raw_input().split())

    pbox(n,a)

Submission status: Wrong Answer

Solution code:
N = int(input())
inf = input().split()
A = {i+1:int(inf[i]) for i in range(N)}
ans = {}
keys = list(A.keys())
keys.sort()
for k in keys[::-1]:
  count = 0
  for j in range(2*k, N, k)[::-1]:
    count += A[j]
  ans[k] = (A[k]-(count%2))%2
value = sum(list(ans.values()))
value = sum(list(ans.values()))
print(value)
tag = []
for k in ans.keys():
  if ans[k]:
    tag +=[str(k)]
print(' '.join(tag))

Submission status: Wrong Answer

Solution code:
def pbox(n,a):
    b = [a[j] for j in xrange(n)]
    total = sum(b)
    if total % 2 == 0:
        print 0
    else:
        print 1
        print 1


if __name__ == '__main__':
    n = int(raw_input())
    a = map(int,raw_input().split())

    pbox(n,a)

Submission status: Wrong Answer

Solution code:
a = int(input())
b = list(map(int, input().split()))
b.insert(0, 0)
c = [0] * (a + 1)
e = 0
f = []
for i in range(a, 0, -1):
    d = 0
    for j in range(i, a, i):
        d += c[j]
    if d % 2 != b[i]:
        c[i] = 1
        e += 1
        f.append(str(i + 1))
print(e)
if e > 0:
    f.sort()
    print(" ".join(f) if e > 1 else f[0])

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
b = [False] * n
for i in range(n - 1, -1, -1):
    if sum(b[i::i+1]) != a[i]:
        b[i] = True
res = [str(x + 1) for x, v in enumerate(b) if v]
print(len(res))
if len(res) > 0:
    print(' '.join(res))

Submission status: Wrong Answer

Solution code:
a = int(input())
b = list(map(int, input().split()))
c = [0] * a
e = 0
f = []
for i in range(a-1, -1, -1):
    d = 0
    for j in range(i, a, i + 1):
        d += c[j]
    if d != b[i]:
        c[i] = 1
        e += 1
        f.append(str(i + 1))
print(e)
if e > 0:
    f.sort()
    print(" ".join(f) if e > 1 else f[0])

Submission status: Wrong Answer

Solution code:
a = int(input())
b = list(map(int, input().split()))
c = [0] * a
e = 0
f = []
for i in range(a-1, -1, -1):
    d = 0
    for j in range(i, a-1, i + 1):
        d += c[j]
    if d != b[i]:
        c[i] = 1
        e += 1
        f.append(str(i + 1))
print(e)
if e > 0:
    f.sort()
    print(" ".join(f) if e > 1 else f[0])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
b = []
for i in range(n - 1, -1, -1):
    if sum(a[i::i+1]) == 1:
        b.append(i)
print(len(b))
print(' '.join([str(x + 1) for x in b]))

Submission status: Wrong Answer

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

def main():
	n = int(input().strip())
	a = []
	a.append(0)
	a.extend(list(map(int, input().strip().split())))
	s = [0] * (n+1)
	for i in reversed(range(1, n+1)):
		j = 1
		d = 0
		while i * j <= n:
			d += a[i*j]
			j += 1
		s[i] = d % 2
	M = sum(s)
	print(M)
	for i in range(n+1):
		if s[i] == 1:
			print("{} ".format(i), end="")
	print("")

if __name__ == '__main__':
	main()

Submission status: Wrong Answer

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

def main():
	n = int(input().strip())
	a = []
	a.append(0)
	a.extend(list(map(int, input().strip().split())))
	s = [0] * (n+1)
	for i in reversed(range(1, n+1)):
		j = 1
		d = 0
		while i * j <= n:
			d += a[i*j]
			j += 1
		s[i] = d % 2
	M = sum(s)
	print(M)
	for i in range(n+1):
		if s[i] == 1:
			print(i)

if __name__ == '__main__':
	main()

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
import numpy as np
# print(n)
# print(a)
if n==1:
    m = 1
    b = a[0]
else:
    h = int(np.floor(n/2))
    # print("h={}".format(h))
    boxes = np.zeros(n)
    boxes[h:] = a[h:]
    if n%2==0:       
        for i in range(h):
            d = n-h-i-1
            s = sum(boxes[2*(d+1)-1::d+1])%2
            if s==a[d]:
                boxes[d] = 0
            else:
                boxes[d] = 1
        # print("ans_even={}".format(boxes))
        ans = list(map(int, boxes))
        print(sum(ans))
        for i in range(len(ans)):
            if ans[i]==1:
                print("{} ".format(i+1), end="")
    else:
        for i in range(h):
            d = n-h-i-2
            s = sum(boxes[2*(d+1)-1::d+1])%2
            if s==a[d]:
                boxes[d] = 0
            else:
                boxes[d] = 1
        # print("ans_odd={}".format(boxes))
        ans = list(map(int, boxes))
        print(sum(ans))
        for i in range(len(ans)):
            if ans[i]==1:
                print("{} ".format(i+1), end="")

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
import numpy as np
# print(n)
# print(a)
if n==1:
    m = 1
    b = a[0]
else:
    h = int(np.floor(n/2))
    # print("h={}".format(h))
    boxes = np.zeros(n)
    boxes[h:] = a[h:]
    if n%2==0:       
        for i in range(h):
            d = n-h-i-1
            s = sum(boxes[2*(d+1)-1::d+1])%2
            if s==a[d]:
                boxes[d] = 0
            else:
                boxes[d] = 1
        # print("ans_even={}".format(boxes))
        ans = list(map(int, boxes))
        print(*ans)
    else:
        for i in range(h):
            d = n-h-i-2
            s = sum(boxes[2*(d+1)-1::d+1])%2
            if s==a[d]:
                boxes[d] = 0
            else:
                boxes[d] = 1
        # print("ans_odd={}".format(boxes))
        ans = list(map(int, boxes))
        print(*ans)

Submission status: Wrong Answer

Solution code:
#D問題
N = int(input())
A = list(map(int,input().split()))
C = [0 for i in range(N)]
for i in range(N):
    I = N-1-i
    n = N//(I+1)
    check = 0
    for j in range(n):
        check+=C[(I+1)*(j+1)-1]
    
    
    if A[I] == check:
        C[I] = 0
    else:
        C[I] = 1

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

Submission status: Wrong Answer

Solution code:
#D問題
N = int(input())
A = list(map(int,input().split()))
C = [0 for i in range(N)]
for i in range(N):
    I = N-1-i
    n = N//(I+1)
    check = 0
    for j in range(n):
        check+=C[I*(j+1)]
    
    
    C[I] = (A[I]-check)%2

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

Submission status: Wrong Answer

Solution code:
#D問題
N = int(input())
A = list(map(int,input().split()))
C = [0 for i in range(N)]
for i in range(N):
    I = N-1-i
    n = N//(I+1)
    check = 0
    for j in range(n):
        if n == 1:
            C[I] = A[I]
        else:
            if j == 0:
                pass
            else:
                check+=C[I*(j+1)]
    if n!= 1:
        C[I] = (A[I]-check)%2

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

Submission status: Wrong Answer

Solution code:
#D問題
N = int(input())
A = list(map(int,input().split()))
C = [0 for i in range(N)]
for i in range(N):
    I = N-1-i
    n = N//(I+1)
    check = 0
    for j in range(n):
        if n == 1:
            C[I] = A[I]
        else:
            if j == 0:
                pass
            else:
                check+=C[I*(j+1)]
                check%=2
    if n!= 1:
        C[I] = (A[I]-check)%2

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

Submission status: Wrong Answer

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

A = [0] + A_init
for i in range(N//2, 0, -1):
    if sum(A[i::i])%2==A[i]:
        A[i] = 1
    else:
        A[i] = 0

ans = [i for i in range(1, N+1) if A[i]]

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

Submission status: Wrong Answer

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

A = [0] + A_init
for i in range(N//2, 0, -1):
    if sum(A[i::i])==A[i]:
        A[i] = 1
    else:
        A[i] = 0

ans = [i for i in range(1, N+1) if A[i]]

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

Submission status: Wrong Answer

Solution code:
import sys

M = int(input())

b_list = list(map(int, input().split()))
b_list.insert(0,0)
result_list = [0] * (M+1)

def getCount(index):
    multi = 2
    count = 0
    while True:
        next_index = index * multi
        if next_index > M:
            break
        count += b_list[next_index]
        multi += 1
    
    return count
        

for i in range(M, 0, -1):
    num = b_list[i]
    count = getCount(i)
    if count % 2 == num:
        result_list[i] = 0
    else:
        result_list[i] = 1

result_list.pop(0)
ans = ""
for i in range(len(result_list)):
    if result_list[i] == 1:
        ans += str(i+1) + " "

print(result_list.count(1))
if ans != "":
    print(ans)

Submission status: Wrong Answer

Solution code:
import sys

M = int(input())

b_list = list(map(int, input().split()))
b_list.insert(0,0)
result_list = [0] * (M+1)

def getCount(index):
    multi = 2
    count = 0
    while True:
        next_index = index * multi
        if next_index > M:
            break
        count += b_list[next_index]
        multi += 1
    
    return count
        

for i in range(M, 0, -1):
    num = b_list[i]
    count = getCount(i)
    if count == num:
        result_list[i] = 0
    elif count == num - 1:
        result_list[i] = 1
    else:
        print(-1)
        sys.exit(0)

result_list.pop(0)
ans = ""
for i in range(len(result_list)):
    if result_list[i] == 1:
        ans += str(i+1) + " "

print(result_list.count(1))
if ans != "":
    print(ans)

Submission status: Wrong Answer

Solution code:
from sys import stdin


def main():
    N = int(input())
    a_lists = [int(x) for x in stdin.readline().rstrip().split()]

    for n in range(N)[1:N+1:-1]:
        n_multiple = [x for x in a_lists if x % n == 0]
        if sum(n_multiple) % 2 == 0:
            a_lists[n-1] = 0
        else:
            a_lists[n-1] = 1

    ansaer = [i+1 for i, x in enumerate(a_lists) if x == 1]

    print(len(ansaer))
    if len(ansaer) == 0:
        pass
    else:
        s = ' '.join([str(n) for n in ansaer])
        print(s)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
from sys import stdin


def main():
    N = int(input())
    a_lists = [int(x) for x in stdin.readline().rstrip().split()]

    for n in range(N)[1:N+1:-1]:
        n_multiple = [x for x in a_lists if x % n == 0]
        if sum(n_multiple) % 2 == 0:
            a_lists[n-1] = 0
        else:
            a_lists[n-1] = 1

    ansaer = [i+1 for i, x in enumerate(a_lists) if x == 1]

    print(len(ansaer))
    if len(ansaer) == 0:
        pass
    else:
        for a in ansaer:
            print(a, " ")


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
a = int(input())
b = list(map(int, input().split()))
c = [0] * (a + 1)
e = []
for i in range(len(b), 0, -1):
    d = 0
    for j in range(i, a, i):
        d += c[j]
    if d % 2 != b[i-1]:
        c[i] += 1
        e.append(str(i))
f = sum(c)
print(f)
if len(e) > 1:
    print(" ".join(e))
elif len(e) == 1:
    print(e[0])

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [int(_) for _ in input().split()]

# A = [0, 0, 0, 0, 0]
# N = len(A)

A_ind = list(range(1, len(A) + 1))
ans = [0 for x in list(range(N))]
ans_M = []
print(len(ans))
def fill_box(i):
    sub_arr = list(filter(lambda x : x % i == 0, A_ind))
    A_sub = [A[j-1] for j in sub_arr]
    ans[i-1] = sum(A_sub) % 2
    if ans[i-1] == 1:
        ans_M.append(i)
    # print(ans)

for i in range(N):
    fill_box(i + 1)

print(len(ans_M))
for i in ans_M:
    print(i)

Submission status: Wrong Answer

Solution code:
import numpy as np
if __name__ == "__main__":
    N = int(input())
    A = list(map(int, input().split()))
    bestcnt = 0
    bestcntA = []
    judge = 0
    for i in range(N):
        tmpA = A[i::(i+1)]
        countA = tmpA.count(1)
        judge = countA % 2
        if judge == 1:
            bestskip = i
            bestlist = np.array(tmpA)
            break
    if judge == 0:
        print(-1)
    else:
        oneindex = np.where(bestlist==1)
        oneindex = oneindex[0]
        print(len(oneindex))
        for i in range(len(oneindex)):
            print((oneindex[i]+1)*(bestskip+1),end = " ")

Submission status: Wrong Answer

Solution code:
n=int(input())
a=[0]+[int(x) for x in input().split()]
b=[0]*(n+1)
 
for s in range(n,0,-1):
    i=s
    t=0
    while i<=n:
        t += b[i]
        i += s
    if a[s]!=t%2:
        b[s]=1
print(b.count(1))
for i in range(1,n):
    if b[i]==1:
        print(i)

Submission status: Wrong Answer

Solution code:
import numpy as np
import sys
N = int(input())
A = list(map(int, input().split()))
result = np.zeros(N)
num = []
for i in range(N-1, -1, -1):
  if A[i] != np.sum(result[i::(i+1)]):
    result[i] = 1
    num.append(str(i+1))

if A[0] != np.sum(result):
  print(-1)
  sys.exit(0)

print(int(np.sum(result)))
print(" ".join(num))

Submission status: Wrong Answer

Solution code:
import numpy as np
import sys
N = int(input())
A = list(map(int, input().split()))
result = np.zeros(N)
for i in range(N-1, -1, -1):
  if A[i] != np.sum(result[i::(i+1)]):
    result[i] = 1

print(int(np.sum(result)))
for i in result:
  if i == 1:
    print(1)

Submission status: Wrong Answer

Solution code:
import numpy as np
import sys
N = int(input())
A = list(map(int, input().split()))
result = np.zeros(N)
for i in range(N-1, -1, -1):
  if A[i] == 1 and np.sum(result[i::(i+1)]) != 1:
    result[i] = 1

if A[0] != np.sum(result):
  print(-1)
  sys.exit(0)

print(int(np.sum(result)))
for i in result:
  if i == 1:
    print(1)

Submission status: Wrong Answer

Solution code:
import numpy as np
import sys
N = int(input())
A = list(map(int, input().split()))
result = np.zeros(N)
for i in range(N-1, -1, -1):
  if A[i] != np.sum(result[::(i+1)]):
    result[i] = 1

if A[0] != np.sum(result):
  print(-1)
  sys.exit(0)

print(int(np.sum(result)))
for i in result:
  if i == 1:
    print(1)

Submission status: Wrong Answer

Solution code:
import numpy as np
import sys
N = int(input())
A = list(map(int, input().split()))
result = np.zeros(N)
for i in range(N-1, -1, -1):
  if A[i] == 1 and np.sum(result[::(i+1)]) != 1:
    result[i] = 1

if A[0] != np.sum(result):
  print(-1)
  sys.exit(0)

print(int(np.sum(result)))
for i in result:
  if i == 1:
    print(1)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [int(i) for i in input().split()]
b = [0] * n
ans = []
for i in range(n, 0, -1):
    b[i - 1] = sum(a[i - 1:n:i]) % 2
    if b[i - 1] == 1:
        ans.append(str(i))
if a == b:
    print(len(ans))
    if len(ans) > 0:
        print(" ".join(ans))
else:
    print("-1")

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [int(i) for i in input().split()]
ans = []
for i in range(n):
    if a[i] == 1:
        ans.append(str(i+1))
print(len(ans))
print(" ".join(ans))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [int(i) for i in input().split()]
ans = []
for i in range(n):
    if a[i] == 1:
        ans.append(str(i+1))
print(len(ans))
for ans_i in ans:
    print(ans_i)

Submission status: Wrong Answer

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


def returnResMod2(i):
    # i+1の倍数の箱のaiの和の剰余を求める
    res = sum([ansList[N-k*(i+1)-1] for k in range(N//(i+1))]) % 2
    return res


ansList = [0 for i in range(N)]
for i in range(N-1, -1, -1):
    tmp = (returnResMod2(i)+A[i]) % 2
    ansList[i] = tmp


M = sum(ansList)
print(M)
if M == 0:
    quit()
print(' '.join([str(i+1) for i, a in enumerate(ansList) if a == 1]))

Submission status: Wrong Answer

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


def returnResMod2(i):
    # i+1の倍数の箱のaiの和の剰余を求める
    res = sum([ansList[k] for k in range(N) if (k+1) % (i+1) == 0]) % 2
    return res


ansList = [0 for i in range(N)]
for i in range(N-1, -1, -1):
    tmp = (returnResMod2(i)+A[i]) % 2
    ansList[i] = tmp


M = sum(ansList)
print(M)
if M == 0:
    quit()
print(' '.join([str(i) for i, a in enumerate(ansList) if i == 1]))

Submission status: Wrong Answer

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

bList=[0] * N

for i in reversed(range(N)):
    x = N // (i + 1)
    tmp = 0
    for j in range(1, x+1):
        tmp += bList[j * (i + 1) - 1]
    if aList[i] != tmp:
        bList[i] = 1
M = bList.count(1)

print(M)
if M != 0:
    for i in range(N):
        if bList[i] == 1:
            print(str(i+1), end = " ")

Submission status: Wrong Answer

Solution code:
def main():
    n = int(input())
    a = [int(x) for x in input().split()]
    b = [0]*n
    for i in reversed(range(n)):
        x = n//(i+1)
        now = 0
        for j in range(1,x+1):
            now += b[x*(i+1)-1]
        if a[i] != now%2:
            b[i]=1
    m = b.count(1)
    print(m)
    if not m==0:
        for i in range(n):
            if b[i]==1:
                print(str(i+1),end=" ")
    
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N = int(input())
a_s = list(map(int,input().split()))
b_s = [0] * N
answers = []
for i,a in enumerate(list(reversed(a_s))):
    k = len(a_s)-i-1
    if a_s[k] - sum(b_s[k::(k+1)])%2 == 1:
        b_s[k] = 1
        answers.append(str(k+1))
print(len(answers))
print(" ".join(list(reversed(answers))))

Submission status: Wrong Answer

Solution code:
N = int(input())
a_s = list(map(int,input().split()))
b_s = []
for i,a in enumerate(list(reversed(a_s))):
    k = len(a_s)-i-1
    if sum(a_s[k::(k+1)])%2 == 1:
        b_s.append(str(k+1))
print(len(b_s))
print(" ".join(list(reversed(b_s))))

Submission status: Wrong Answer

Solution code:
import math
m = list(map(int, input().split()))[0]
a = list(map(int, input().split()))


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
  
b = [False for i in range(m)]

for i in range(m):
    ii = m - i
    if(a[ii-1] != b[ii-1]):
        k = make_divisors(ii)
        for j in k:
            b[j-1] = not b[j-1]

ans = ""
count = 0
for i in range(m):
    if(b[i] == True):
        ans+= str(i+1) + " "
        count +=1
        
print(count)
print(ans)

Submission status: Wrong Answer

Solution code:
import math

N = int(input())
a = list(map(int,input().split()))
b = [0] * N

for i in reversed(range(N)):
        x = math.ceil(N/(i+1))
        temp = 0
        for k in range(x):
            temp = temp + b[k*(i+1) - 1]
        if a[i] != (temp%2):
            b[i] = 1
M = b.count(1)
print(M)
if M != 0:
    for i in range(N):
        if b[i] ==1:
            print(str(i+1), end = "")
            temp1=i+1
            break
    for i in range(temp1,N):
        if b[i] ==1:
            print(" "+ str(i+1), end = "")