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

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 _ in range(N):
    n = deq.pop()
    if sum(B[2*n-1:N:n])%2 != A[n-1]:
        B[n-1] = 1

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

Submission status: Wrong Answer

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



def sol(i,want):
    num=N//(i+1)
    wa=A[i]

    for j in range(num):
        wa+=A[(i+1)+j*(i+1)-1]
#         print(i+j*i)
#     print(i,wa,A[i])
    wa=wa%2
#     print(i,wa,A[i])
    
    if wa==want:
        x=0
    else:
        x=1
#     print(num)
    return x 

B=A[:]
half=N//2
for i in range(half):
    j=half-1-i
#     print(sol(j,A[j]))
    B[j]=sol(j,A[j])
    
C=[i+1 for i, x in enumerate(B) if x ==1]

m=sum(B)
print(m)
print(*C)

Submission status: Wrong Answer

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

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

for i in range(N):
    base = N - 1 - i
    for j in range(base, N, base+1):
        if j == base:
            ans[i] += A[j]
        else:
            ans[i] -= ans[N - 1 - j]

    if ans[i] < 0:
        print('-1')
        break
else:
    ans_ids = [str(i+1) for i, a in enumerate(reversed(ans)) if a == 1]
    print(len(ans_ids))
    print(' '.join(ans_ids))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
b = [0 for _ in range(n)]
for i in range(n-1, -1, -1):
	tmp = 0
	for j in range(2*(i+1), n, i+1):
		tmp ^= b[j]
	b[i] = a[i]^tmp
ans = [i+1 for i in range(n) if b[i]]
print(len(ans))
print(*ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
b = [0 for _ in range(n)]
for i in range(n-1, -1, -1):
	tmp = 0
	for j in range(2*(i+1), n, i+1):
		tmp += b[j]
	b[i] = a[i]^tmp
ans = [i+1 for i in range(n) if b[i]]
print(len(ans))
print(*ans)

Submission status: Wrong Answer

Solution code:
n,*a=map(int,open(0).read().split())
b=[0]*-~n
for i in range(n,0,-1):
    if a[i-1]:
        for j in range(i,n+1,i):
            if b[j]:break
        else:b[i]=1
c=[i for i,b in enumerate(b)if b]
print(len(c),*c)

Submission status: Wrong Answer

Solution code:
import sys
line = sys.stdin.readline
M = int(line())
b = list(map(int, line().split()))
c = [0] * M
for i in range(1, M + 1):
    ball = 0
    for j in range(2, M+1):
        if i * j > M:
            break
        ball += c[i * j - 1]
    c[i - 1] = (b[i - 1] + ball) % 2
ans = []
for i, v in enumerate(c):
    if v == 1:
        ans.append(i + 1)
print(len(ans))
print(*ans)

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

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)

for _ in range(N):
    n = deq.pop()
    if sum(A[n-1:N:n])%2 != A[n-1]:
        print(-1)
        exit()

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

Submission status: Wrong Answer

Solution code:
import math

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

for i in range(1, N+1)[::-1]:
    ans_bit = sum(a[i::i]) % 2
    if a[i] != ans_bit:
        print(-1)
        exit()

ans = [index for index, v in enumerate(a) if v == 1]
print(len(ans))
print(*ans)

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):
    if not sum(b[i::i+1]) % 2 == a[i]:
        b[i]=1
print(sum(b))
if b:
    print(*[i for i in b if i==1])

Submission status: Wrong Answer

Solution code:
n=int(input())
arr=list(map(int,input().split()))
flag=[-1]*n
ans=[]
for i in range(n-1,-1,-1):
  cnt=0
  for j in range(i+1,n,i+1):
    if flag[j]==1:
      cnt+=1
  if (arr[i]+cnt)%2==0:
    flag[i]=0
  else:
    flag[i]=1
    ans.append(i+1)
num=len(ans)
if num==0:
  print(0)
else:
  print(num)
  print(*ans)

Submission status: Wrong Answer

Solution code:
n,*a=map(int,open(0).read().split())
b=[0]*-~n
for i,a in enumerate(a,1):
    if a:
        b[i]=1
        b[i//2]=0
c=[i for i,b in enumerate(b)if b]
print(len(c),*c)

Submission status: Wrong Answer

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

idxs = list(reversed([i+1 for i in range(N)]))

box=[0 for i in range(N)]
for idx in idxs:
    div = [i*idx for i in range(N //idx)]
    sum_=sum([box[c] for c in div])
    if sum_ % 2 != l[idx-1]:
        box[idx-1] = 1

print(sum(box))
for i, v in enumerate(box):
    if v==1:
        print(i+1, end=' ')

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):
    if not sum(b[i::i+1]) % 2 == a[i]:
        b[i]=1
print(sum(b))
print(*[i for i in b if i==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]

count = 0
for i in reversed(range(1,n+1)):
    j = 2
    b_sum = 0
    while i * j <= n:
        b_sum += b[i*j]
        j += 1

    if not (b_sum % 2) == a[i-1]:
        b[i] = 1
        count += 1

if count <= 0:
    print(0)
else:
    for i in range(count):
        if i == count - 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().split())))

primes = []
pr_array = np.zeros(n+1)
if sum(a)==0:
    print('0')
    exit()
for i in range(n-1,-1,-1):
    num = i + 1
    if a[i]==1:
        if len(primes) == 0:
            primes.append(num)
            pr_array[num] = 1
            continue
        cnt = 0
        for mul in range(num*2,n+1,num):
            cnt += pr_array[mul]
        if cnt%2==0:
            primes.append(num)
            pr_array[num] = 1

print(len(primes))
print(*primes)
print()

Submission status: Wrong Answer

Solution code:
import numpy as np
n = int(input())
a = np.array(list(map(int,input().split())))

primes = []
pr_array = np.zeros(n+1)
if sum(a)==0:
    print('0')
    exit()
for i in range(n-1,-1,-1):
    num = i + 1
    if a[i]==1:
        if len(primes) == 0:
            primes.append(num)
            pr_array[num] = 1
            continue
        cnt = 0
        for mul in range(num*2,n+1,num):
            cnt += pr_array[mul]
        if cnt%2==0:
            primes.append(num)
            pr_array[num] = 1

print(len(primes))
print(*primes)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int, input().split()))
a.insert(0,0)
b = [0] * (N + 1)
ans = []
count = 0
for i in reversed(range(1,N + 1)):
  if a[i] == 1:
    sumi = 0
    j = 2
    while True:
      if (i * j) > N:
        break
      sumi += b[i * j]
      j += 1
    if sumi % 2 == 0:
      b[i] = 1
      count += 1
      ans.append(int(i))
ans.sort()
print(count)
print(' '.join(map(str, ans)))

Submission status: Wrong Answer

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

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

b = [0]*n

for i in range(n):
    c = divisors(a[i])
    for x in c:
        b[x-1]+=1

ans = []

for i in range(n):
    if b[i]%2==1:
        ans.append(i+1)
print(len(ans))
for i in range(len(ans)):
    print(ans[i],end=' ')

Submission status: Wrong Answer

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

total = 0
b = set()
for i in range(N):
    tmpBall = 0
    for j in b:
        if j % (N - i):
            tmpBall = tmpBall + 1
    if tmpBall % 2 != a[N - i - 1]:
        total = total + 1
        b.add(N - i)

print(total)
for k in b:
    print(k)

Submission status: Wrong Answer

Solution code:
import copy

N = int(input())
a = list(map(int, input().split()))
a.insert(0,0)
b = [0] * (N + 1)
ans = []
count = 0
for i in reversed(range(1,N + 1)):
  if a[i] == 1:
    sumi = 0
    j = 2
    while True:
      if (i * j) > N:
        break
      sumi += b[i * j]
      j += 1
    if sumi % 2 == 0:
      b[i] = 1
      count += 1
      ans.append(int(i))
print(count)
print(' '.join(map(str, ans)))

Submission status: Wrong Answer

Solution code:
def resolve():
    n = int(input())
    a = [0]
    a.extend( list(map(int,input().split())) )
    #prime(2)
    tmp = [0]*(n+1)
    ans = []
    for i in range(1,n+1):
        sum = 0
        for j in range(i+i,n+1,i):
            sum = sum^tmp[j]
        tmp[i] = sum^a[i]
    for i in range(1,n+1):
        if(tmp[i]>0):
            ans.append(i)
    
    print(len(ans))
    for i in ans:
        print(i)

if __name__ == "__main__":
    resolve()

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]

count = 0
for i in reversed(range(1,n+1)):

    j = 2
    b_sum = 0
    while i * j <= n:
        b_sum += b[i*j]
        j += 1

    if not (b_sum % 2) == a[i-1]:
        b[i] = 1
        count += 1

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

Submission status: Wrong Answer

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

def sol(i,want):
    num=int(N/(i+1))
    wa=-A[0]
    for j in range(num):
        wa+=A[i+j*i]
    wa=wa%2
    if wa==want:
        x=0
    else:
        x=1
#     print(num)
    return x 

B=A[:]
half=int(N/2)
for i in range(half):
    j=half-1-i
#     print(j)
    B[j]=sol(j,A[j])
    
C=[]
for i in range(N):
    if B[i]==1:
        C.append(i+1)
m=sum(B)

print(m)
print(*C)

Submission status: Wrong Answer

Solution code:
import copy

N = int(input())
a = list(map(int, input().split()))
a.insert(0,0)
b = [0] * (N + 1)
ans = []
count = 0
for i in reversed(range(N)):
  if a[i] == 1:
    sumi = 0
    j = 2
    while True:
      if (i * j) >= N:
        break
      sumi += b[i * j]
      j += 1
    if sumi % 2 == 0:
      b[i] = 1
      count += 1
      ans.append(int(i))
print(count)
print(' '.join(map(str, ans)))

Submission status: Wrong Answer

Solution code:
N=int(input())
Arr=[0]+[int(thing) for thing in input().split(" ")]
Box=[0 for i in range(N+1)]

for i in range(N-1):
    i=N-i
    baisu=[i*j for j in range(N//i)]
    bit=sum([Box[j] for j in baisu])//2
    if Arr[i]==0:
        if bit==0:
            Box[i]=0
        else:
            Box[i]=1
            
    else:
        if bit==0:
            Box[i]=1
        else:
            Box[i]=0

print(sum(Box))
print(" ".join([str(i+1) for i in range(len(Box)) if Box[i]==1]))

Submission status: Wrong Answer

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

ball = [0] * n

for i in reversed(range(n//2)):
    sum_ball = 0
    for j in range(1, n//(i+1)):
        sum_ball += ball[(i+1)*(j+1)-1]
    if sum_ball % 2 != a[i]:
        ball[i] = 1

index = [i+1 for i, x in enumerate(ball) if x == 1]
l = len(index)
print(l)
if l > 0:
    print(" ".join(map(str, index)))

Submission status: Wrong Answer

Solution code:
import copy

N = int(input())
a = list(map(int, input().split()))
a.insert(0,0)
b = [0] * N
ans = []
count = 0
for i in reversed(range(N)):
  if a[i] == 1:
    sumi = 0
    j = 2
    while True:
      if (i * j) >= N:
        break
      sumi += b[i * j]
      j += 1
    if sumi % 2 == 0:
      b[i] = 1
      count += 1
      ans.append(int(i))
print(count)
print(' '.join(map(str, ans)))

Submission status: Wrong Answer

Solution code:
N = int(input())
l = list(map(int,input().split(' ')))
mid = N // 2
MAP = [0]*N
ans_l = []

for i in range(N,0,-1):
    s = N // i + 1
    t = 0
    for j in range(1,N):
      if i*j<=N-1:
        t += MAP[i*j-1]
      else:
        break
    if t%2 != l[i-1]:
        ans_l.append(str(i))
        MAP[i-1] = 1
leng = len(ans_l)
print(leng)
print(" ".join(ans_l))

Submission status: Wrong Answer

Solution code:
N = int(input())
l = list(map(int,input().split(' ')))
mid = N // 2
MAP = [0]*N
ans_l = []

for i in range(N,0,-1):
    s = N // i + 1
    t = 0
    for j in range(1,N):
      if i*j<=N:
        t += MAP[i*j-1]
      else:
        break
    if t%2 != l[i-1]:
        ans_l.append(str(i))
        MAP[i-1] = 1
leng = len(ans_l)
print(leng)
print(" ".join(ans_l))

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)

count = 0
for i in reversed(range(1,n+1)):

    j = 2
    b_sum = 0
    while i * j <= n:
        b_sum += b[i*j]
        j += 1

    if not (b_sum % 2) == a[i-1]:
        b[i] = 1
        count += 1

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

Submission status: Wrong Answer

Solution code:
import numpy as np
n = int(input())
a = np.array(list(map(int,input().split())))

primes = []
pr_array = np.zeros(n+1)
if sum(a)==0:
    print('0')
    exit()
for i in range(n-1,-1,-1):
    num = i + 1
    if a[i]==1:
        if len(primes) == 0:
            primes.append(num)
            pr_array[num] = 1
            continue
        cnt = 0
        for mul in range(2,int(n/num)+1):
            cnt += pr_array[num * mul]
        if cnt%2==0:
            primes.append(num)
            pr_array[num] = 1

print(len(primes))
print(*primes)

Submission status: Wrong Answer

Solution code:
import numpy as np
n = int(input())
a = np.array(list(map(int,input().split())))

primes = []
pr_array = np.zeros(n+1)
if sum(a)==0:
    print('0')
    exit()
for i in range(n-2,-1,-1):
    num = i + 1
    if a[i]==1:
        if len(primes) == 0:
            primes.append(num)
            pr_array[num] = 1
            continue
        cnt = 0
        for mul in range(2,int(n/num)+1):
            cnt += pr_array[num * mul]
        if cnt%2==0:
            primes.append(num)
            pr_array[num] = 1

print(len(primes))
print(*primes)

Submission status: Wrong Answer

Solution code:
N=int(input())
box=[0]*N
ans=[]
a_list=list(map(int,input().split(' ')))
for i in range(N,0,-1):
    sum=0
    for j in range(1,N):
        #print("{}:{}".format(i,j))
        if j*i<= N:
            sum+=box[j*i-1]
        else:
            break
    if sum%2 != a_list[i-1]:
        box[i-1]=1
        ans.append(str(i))
sum=0
print(len(ans))
print(" ".join(ans))

Submission status: Wrong Answer

Solution code:
N=int(input())
box=[0]*N
ans=[]
a_list=list(map(int,input().split(' ')))
for i in range(N,0,-1):
    sum=0
    for j in range(1,N):
        #print("{}:{}".format(i,j))
        if j*i<= N:
            sum+=box[j*i-1]
        else:
            break
    if sum%2 != a_list[i-1]:
        box[i-1]=1
        ans.append(str(i+1))
sum=0
print(len(ans))
print(" ".join(ans))

Submission status: Wrong Answer

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


if a[-1] == 1:
        ball[-1] = 1

for i in reversed(range(1, N+1)):
        tmp = 0
        for j in range(i + i, N + 1, i):
                tmp ^= ball[j]

        #print(i+1, tmp, a[i])
        ball[i] = tmp ^ a[i]

#print(ball)

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

Submission status: Wrong Answer

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


if a[-1] == 1:
        ball[-1] = 1

for i in reversed(range(1, N+1)):
        tmp = 0
        for j in range(i + i, N + 1, i):
                tmp ^= a[j]

        #print(i+1, tmp, a[i])
        ball[i] = tmp ^ a[i]

#print(ball)

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

Submission status: Wrong Answer

Solution code:
import numpy as np
n = int(input())
a = np.array(list(map(int,input().split())))

primes = []
pr_array = np.zeros(n+1)
if sum(a)==0:
    print('0')
    exit()
primes.append(n)
pr_array[n] = 1
for i in range(n-2,-1,-1):
    num = i + 1
    if a[i]==1:
        cnt = 0
        for mul in range(2,int(n/num)+1):
            cnt += pr_array[num * mul]
        if cnt%2==0:
            primes.append(num)
            pr_array[num] = 1

print(len(primes))
print(*primes)

Submission status: Wrong Answer

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


if a[-1] == 1:
        ball[-1] = 1

for i in reversed(range(1, N+1)):
        tmp = 0
        for j in range(i + i, N + 1, i):
                #print("i j ", i , j)
                if j % i == 0:
                        tmp ^= a[j]

        #print(i+1, tmp, a[i])
        ball[i] = tmp ^ a[i]

#print(ball)

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

Submission status: Wrong Answer

Solution code:
import sys

def solve(N, a):
    balls = [0] * (N+1)
    for i in range(N, 0, -1):
        s = sum([ balls[j] for j in range(i, N+1, i) ])
        if a[i] != s % 2:
            balls[i] += 1

    ans = []
    for i in range(1, N):
        if balls[i] % 2 == 1:
            ans.append(i)
    
    print(len(ans))
    for x in ans:
        print(x, end=' ')


def main():
    N = int(input())
    a = list(map(int, input().split()))
    a.insert(0, [])
    solve(N, a)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def get_divisor(n):
    if n==1:return [1]
    a = [1]
    b = [n]
    for i in range(2,int(n**0.5)):
        if n%i==0:
            a.append(i)
            b.append(n//i)
    if int(n**0.5)**2==n:b.pop()
    a.extend(b[::-1])
    return a

N = int(input())
*A, = map(int,input().split())
D = [0]*(N+1)
ans = []
for i in range(N,0,-1):
    if D[i]%2 != A[i-1]:
        ans.append(i)
        for j in get_divisor(i):
            D[j]+=1
print(len(ans))
print(*ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
box=[0]*N
ans=[]
a_list=list(map(int,input().split()))
sum=0
for i in range(N-1,-1,-1):
    for j in range(1,N):
        #print("{}:{}".format(i,j))
        if j*(i+1) <= N:
            sum+=box[j*(i+1)-1]
        else:
            break
    if sum%2 != a_list[i]:
        box[i]=1
        ans.append(str(i+1))
    sum=0
sum=0
print(len(ans))
print(" ".join(ans))

Submission status: Wrong Answer

Solution code:
import copy

N = int(input())
a = list(map(int, input().split()))
b = [0] * N
ans = []
count = 0
for i in reversed(range(N)):
  if  i == 0:
    if a[i] == 1:
      if (count % 2) == 0:
#        print(count)
        b[i] = 1
        count += 1
        ans.append(int(i+1))
  else:
    if a[i] == 1:
      sumi = 0
      j = 2
      while True:
        if (i * j) >= N:
#          print("i:",i)
          break
        sumi += b[i * j]
        j += 1
      if sumi % 2 == 0:
#        print("sumi:",sumi)
        b[i] = 1
        count += 1
        ans.append(int(i+1))
print(count)
print(' '.join(map(str, ans)))

Submission status: Wrong Answer

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


if a[-1] == 1:
        ball[-1] = 1

for i in reversed(range(1, N)):
        tmp = 0
        for j in range(i + i, N, i):
                #print("i j ", i , j)
                if j % i == 0:
                        tmp ^= a[j]

        #print(i+1, tmp, a[i])
        ball[i] = tmp ^ a[i]

#print(ball)

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

Submission status: Wrong Answer

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

box = [-1] * N
for i in range(N//2+1, N+1):
    box[i-1] = A[i-1]

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

ans = sum(box)
print(sum(box))
if ans > 0:
    for bi, ball in enumerate(box):
        if ball == 1:
            print(bi+1, end=' ')
    print()

Submission status: Wrong Answer

Solution code:
N=int(input())
Arr=[0]+[int(thing) for thing in input().split(" ")]
Box=[0 for i in range(N+1)]

for i in range(N):
    i=N-i
    baisu=[i*j for j in range(N//i)]
    bit=sum([Box[j] for j in baisu])//2
    if Arr[i]==0:
        if bit==0:
            Box[i]=0
        else:
            Box[i]=1

    else:
        if bit==0:
            Box[i]=1
        else:
            Box[i]=0

print(sum(Box))
print(" ".join([str(i) for i in range(len(Box)) if Box[i]==1]))

Submission status: Wrong Answer

Solution code:
import copy

N = int(input())
a = list(map(int, input().split()))
b = [0] * N
ans = []
count = 0
for i in reversed(range(N)):
  if  i == 0:
    if a[i] == 1:
      if (count % 2) == 0:
        print(count)
        b[i] = 1
        count += 1
        ans.append(int(i+1))
  else:
    if a[i] == 1:
      sumi = 0
      j = 2
      while True:
        if (i * j) >= N:
#          print("i:",i)
          break
        sumi += b[i * j]
        j += 1
      if sumi % 2 == 0:
#        print("sumi:",sumi)
        b[i] = 1
        count += 1
        ans.append(int(i+1))
print(count)
print(' '.join(map(str, ans)))

Submission status: Wrong Answer

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


if a[-1] == 1:
        ball[-1] = 1

for i in reversed(range(1, N)):
        tmp = 0
        for j in range(i + i, N, i):
                #print("i j ", i , j)
                if j % i == 0:
                        tmp += a[j]

        #print(i+1, tmp, a[i])
        if tmp % 2 != a[i]:
                ball[i] = 1

#print(ball)

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

Submission status: Wrong Answer

Solution code:
import math

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

for i in range(1, N+1)[::-1]:
    ans_bit = sum(a[i::i]) % 2
    if a[i] != ans_bit:
        print(-1)
        exit()

print(sum(a))
b = [index for index, v in enumerate(a) if v == 1]
if len(b) > 0:
    print(*b)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
INF = float("inf")

MOD = 2  # type: int


import math
import collections


def solve(N: int, a: "List[int]"):
    b = [0]*N
    for i in range(N-1, -1, -1):
        tmp = 0
        for j in range(2, -(-N//(i+1))):
            tmp += b[j*(i+1)]
        if tmp % MOD == a[i]:
            b[i] = 0
        else:
            b[i] = 1

    c = [i+1 for i, val in enumerate(b) if val % 2 > 0]
    print(len(c))
    if len(c) != 0:
        print(*c, sep=" ")
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, a)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N=int(input())
Arr=[0]+[int(thing) for thing in input().split(" ")]
Box=[0 for i in range(N+1)]

for i in range(N):
    i=N-i
    baisu=[i*j for j in range(N//i)]
    bit=sum([Box[j] for j in baisu])//2
    if Arr[i]==0:
        if bit==0:
            Box[i]=0
        else:
            Box[i]=1
            
    else:
        if bit==0:
            Box[i]=1
        else:
            Box[i]=0

print(sum(Box))
print(" ".join([str(i+1) for i in range(len(Box)) if Box[i]==1]))

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:
import numpy as np
n = int(input())
a = np.zeros((n+1))

a_list = np.array(list(map(int, input().strip().split())))

a[1:] = a_list

b = a

for i in reversed(range(1,n+1)):

    j = 2
    b_sum = 0
    while i * j <= n:
        b_sum += b[i*j]
        j += 1

    if not (b_sum % 2) == a[i]:
        b[i] = 1


b = b.astype(int)
b = b[1:]
#print(b)

flag = True
for i in range(n):
    if b[i] < 0:
        flag = False
        break

if flag:
    print(str(b).replace('[','').replace(']','').replace(' 0','').replace('0 ',''))

else:
    print(-1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
INF = float("inf")

MOD = 2  # type: int


import math
import collections


def solve(N: int, a: "List[int]"):
    b = [0]*N
    for i in range(N-1, -1, -1):
        tmp = 0
        for j in range(2, -(-N//(i+1))):
            tmp += b[j*i]
        if tmp % MOD == a[i]:
            b[i] = 0
        else:
            b[i] = 1

    c = [i+1 for i, val in enumerate(b) if val % 2 > 0]
    print(len(c))
    if len(c) != 0:
        print(*c, sep=" ")
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, a)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n = int(input())
a_list = list(map(int,input().split()))
b_list = [0]*(n-n//2)+a_list[(n-n//2):]

for i in range(n//2):
    k = int(n//2-i-1)
    if a_list[k] != sum(b_list[k::k+1])%2:
        b_list[k] = 1

b_list = [i+1 for i,x in enumerate(b_list) if x ==1]
x = len(b_list)
print(x)
if x != 0:
    print(*b_list)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
INF = float("inf")

MOD = 2  # type: int


import math
import collections


def solve(N: int, a: "List[int]"):
    b = [0]*N
    for i in range(N-1, -1, -1):
        tmp = 0
        for j in range(2, N//(i+1)):
            tmp += b[j*i]
        if tmp % MOD == a[i]:
            b[i] = 0
        else:
            b[i] = 1

    c = [i+1 for i, val in enumerate(b) if val % 2 > 0]
    print(len(c))
    if len(c) != 0:
        print(*c, sep=" ")
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, a)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import math

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

for i in range(1, N+1)[::-1]:
    ans_bit = sum(a[i::i]) % 2
    if a[i] != ans_bit:
        print(-1)
        exit()
    i -= 1

print(sum(a))
b = [index for index, v in enumerate(a) if v == 1]
if len(b) > 0:
    print(*b)

Submission status: Wrong Answer

Solution code:
N=int(input())
box=[0]*N
a_list=list(map(int,input().split()))
sum=0
for i in range(N-1,-1,-1):
    for j in range(1,N):
        #print("{}:{}".format(i,j))
        if j*(i+1) <= N:
            if box[j*(i+1)-1]==1:
                sum+=1
        else:
            break
    if sum%2 != a_list[i]:
            box[i]=1
    sum=0
ans=[]
sum=0
for i,k in enumerate(box):
    if k==1:
        sum+=1
        ans.append(str(i+1))
print(sum)
print(" ".join(ans))