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())
b_list = [int(i) for i in input().split()]

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

for idx, i in enumerate(b_list[::-1]):
    _sum = sum(res[N-1 - idx: N: N-idx])
    if _sum % 2 == i:
        pass
    else:
        res[N-1 - idx] = 1

res_sum = sum(res)

print(res_sum)
if res_sum > 0:
    res = [i for idx, i in enumerate(res) if i == 1]
    print(" ".join(str(i) for i in res))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

for i in range(n-1,-1,-1):
    b = [0]*n
    if sum(b[i::i+1])%2 != a[i]:
        b[i] = 1

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

Submission status: Wrong Answer

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

chk = [0]*N

A.reverse()
for i, a in enumerate(A):
    sum_chk = sum(chk[N-i-1::N-i])
    if sum_chk == a-1:
        chk[N-i-1] = 1
        continue
    elif sum_chk == a:
        continue
    else:
        print(-1)
        exit()

M = sum(chk)
b = [i+1 for i, v in enumerate(chk) if v==1]
print(M)
if M != 0: print(*b)

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int,input().split()))
B=[0] * N
flag = False
for i in reversed(range(1, N+1)):
    a = A[i-1]
    for j in range(1, N+1):
        tmp = i * j
        if tmp > N:
            break
        a += B[tmp-1]
    if a % 2 == 1:
        print(i)
        flag = True
    B[i-1] = a % 2
if not flag:
    print(0)

Submission status: Wrong Answer

Solution code:
n = int(input())
ai = [int(x) for x in input().split()]
bn = [0] * n

for i in range(0,n):
    j = n - 1 - i
    c = 0
    for k in range(2, n+1):
        idx = k * (j + 1) - 1
        if  idx >= n-1:
            break
        c += bn[idx]
    
    bn[j] = (c + ai[j]) % 2


m = sum(bn)
print(m)
for i in range(0,n):
    if bn[i] == 1:
        print(i+1, end=" ")

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int,input().split()))
B=[0] * N
flag = False
for i in reversed(range(1, N+1)):
    a = A[i-1]
    for j in range(1, N+1):
        tmp = i * j
        if tmp > N:
            break
        a += B[tmp-1]
    if a % 2 == 1:
        print(i)
        flag = True
    B[i-1] = a
if not flag:
    print(0)

Submission status: Wrong Answer

Solution code:
import sys

N = int(input())
Atmp = [0] + list(map(int, input().split()))
A = {}

for i,a in enumerate(Atmp):
    A[i] = a

#print(A)

X = {}

for i in reversed(list(range(1,N+1))):
    Xsum = 0
    j = 2
    while(i*j <= N):
        Xsum += X[i*j]
        j += 1
        continue
    odd = Xsum % 2
    if odd == A[i]:
        X[i] = 0
    else:
        X[i] = 1
    



def umeru(X, M, last):
    #print('---')
    for i in reversed(list(range(N//(M+1)+1, N//M+1))):
        if M == 1:
            X[i] = A[i]
        else:
            Xsum = 0
            j = 2
            while(i*j < N):
                Xsum += X[i*j]
                j += 1
                continue
            odd = Xsum % 2
            #print(M, i, odd, A[i])
            if odd == A[i]:
                X[i] = 0
            else:
                X[i] = 1
    #print(N,M,X)
    if last:
        return
    if N//(M+1) == 0:
        umeru(X, M+1, True)
    else:
        umeru(X, M+1, False)

#umeru(X, 1, False)
#print(X)

M = 0
for i in range(1, N+1):
    if X[i] == 1:
        M += 1

print(M)
if M == 0:
    sys.exit()

xxx = []
for i in range(1, N+1):
    if X[i] == 1:
        xxx.append(str(X[i]))

print(' '.join(xxx))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math

N = int(input())
a = [0]+list(map(int, input().split()))
ans = [0 for _ in range(N+1)]

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

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

Submission status: Wrong Answer

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

b=[0]*n
for i in range(n,0,-1):
    v=0
    for j in range(i+1,n+1,i):
        v+=b[j-1]
    #b[i-1]=1 if v%2!=a[i-1] else 0
    if v%2!=a[i-1]:
        b[i-1]=1
m=b.count(1)
print m
print "1 " * m

Submission status: Wrong Answer

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

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

for idx, i in enumerate(b_list[::-1]):
    if sum(res[N-1-idx: N: N-idx]) % 2 == i:
        pass
    else:
        res[N-1 - idx] = 1

res_sum = sum(res)

print(res_sum)
if res_sum > 0:
    res = [i for idx, i in enumerate(res) if i == 1]
    print(" ".join(str(i) for i in res))

Submission status: Wrong Answer

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

if len(set(A)) == 1 and A[0] == 0:
  print(0)
else:
  flag=0
  ans = []
  start = N
  for n in range(N+1):
    end = start
    start = N // (n+1)
    if start == end:
      end+=1
    ans += [start+(i+1) for i, x in enumerate(A[start:end]) if x==flag]
    flag = 1 - flag
  ans = list(set(ans))
  print(len(ans))
  print(' '.join([str(n) for n in ans]))

Submission status: Wrong Answer

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

H = [0]*N
for i in range(N,0,-1):
#    print(i)

    if i > N/2:
        H[i-1] = A[i-1]
    else:
        sum = 0
        bai = 1
        while i*bai <= N:
            sum += A[(i*bai)-1]
            bai += 1
        if sum % 2 == 0:
            H[i-1] = 0
        else:
            H[i-1] = 1

M=0
out=[]
for i,h in enumerate(H):
    if h == 1:
        M+=1
        out.append(i+1)
print(M)

for o in out:
    print(str(o)+" ",end='')

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [0] + list(map(int, input().split()))
B = []
for i in range(N+1)[:0:-1]:
  if A[i] != sum(B[2*i:N+1:i])%2:
    B = [i] + B
b_sum = len(B)
print(b_sum)
if b_sum > 0:
  print(' '.join(map(str, B)))

Submission status: Wrong Answer

Solution code:
n = int(input())
ai = [int(x) for x in input().split()]
bn = [0] * n

for i in range(0,n):
    j = n - 1 - i
    c = 0
    for k in range(2, n):
        idx = k * (j + 1) - 1
        if  idx >= n-1:
            break
        c += bn[idx]
    
    bn[j] = (c + ai[j]) % 2


m = sum(bn)
print(m)
for i in range(0,n):
    if bn[i] == 1:
        print(i+1, end=" ")

Submission status: Wrong Answer

Solution code:
import sys
import math

def add_ball(idx):
    add_list = []
    for j in range(1, int(math.sqrt(idx))+1):
        if idx%j == 0:
            add_list.append(j)
            if j != idx//j:
                add_list.append(idx//j)
    for k in add_list:
        b_list[k-1] += 1

if __name__ == "__main__":
    input = sys.stdin.readline

    n = int(input())
    a_list = list(map(int, input().split()))
    b_list = [0] * n
    for i, a in enumerate(a_list[::-1]):
        if a != b_list[-i-1]%2:
            add_ball(n-i)
    ball_list = [i+1 for i, b in enumerate(b_list) if b%2 == 1]
    ball_sum = len(ball_list)
    print(ball_sum)
    if ball_sum > 0:
        print(' '.join(map(str, ball_list)))

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [0] + list(map(int, input().split()))
B = []#[0] * (N+1)
for i in range(N+1)[:0:-1]:
  if A[i] != sum(B[2*i:N+1:i])%2:
    B.append(i)
b_sum = len(B)
print(b_sum)
if b_sum > 0:
  print(' '.join(map(str, B)))

Submission status: Wrong Answer

Solution code:
import sys

N = int(input())
Atmp = [0] + list(map(int, input().split()))
A = {}

for i,a in enumerate(Atmp):
    A[i] = a

#print(A)

X = {}

for i in reversed(list(range(1,N+1))):
    Xsum = 0
    j = 2
    while(i*j < N):
        Xsum += X[i*j]
        j += 1
        continue
    odd = Xsum % 2
    if odd == A[i]:
        X[i] = 0
    else:
        X[i] = 1
    



def umeru(X, M, last):
    #print('---')
    for i in reversed(list(range(N//(M+1)+1, N//M+1))):
        if M == 1:
            X[i] = A[i]
        else:
            Xsum = 0
            j = 2
            while(i*j < N):
                Xsum += X[i*j]
                j += 1
                continue
            odd = Xsum % 2
            #print(M, i, odd, A[i])
            if odd == A[i]:
                X[i] = 0
            else:
                X[i] = 1
    #print(N,M,X)
    if last:
        return
    if N//(M+1) == 0:
        umeru(X, M+1, True)
    else:
        umeru(X, M+1, False)

#umeru(X, 1, False)
#print(X)

M = 0
for i in range(1, N+1):
    if X[i] == 1:
        M += 1

print(M)
if M == 0:
    sys.exit()

xxx = []
for i in range(1, N+1):
    if X[i] == 1:
        xxx.append(str(X[i]))

print(' '.join(xxx))

Submission status: Wrong Answer

Solution code:
import math
def func1(lst, value):
    return [i+1 for i, x in enumerate(lst) if x == value]
N = int(input())
a = list(map(int,input().split()))

b = [0] * N
half = math.ceil(N/2)
summ = 0
for i in reversed(range(N)):
    # print(i)
    # if i >= half-1:
    #     b[i] = a[i]
    # else:
    x = N//(i+1)
    if x == 1:
        b[i] = a[i]
    else:
        for j in range(x):
            summ += a[(i+1)*(j+1)-1]
        summ -= a[i]
        # print("sum=",summ)
        judge=summ%2
        if (judge==0 and a[i]==0) or (judge==1 and a[i]==1):
            b[i] = 0
        else:
            b[i] = 1
        summ = 0
        judge = 0
print(sum(b))
if sum(b) != 0:
    ans = func1(b,1)
    # print(ans)
    if len(ans)>1:
        ans = map(str,ans)
        print(" ".join(ans))
    else:
        print(ans.pop())

Submission status: Wrong Answer

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

b=[0]*n
for i in range(n,0,-1):
    v=0
    for j in range(i,n+1,i):
        v+=b[j-1]
    #b[i-1]=1 if v%2!=a[i-1] else 0
    if v%2!=a[i-1]:
        b[i-1]=1
m=b.count(1)
print m
print "1 " * m

Submission status: Wrong Answer

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

MOD = 2  # type: int


import math
import collections


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


def solve(N: int, a: "List[int]"):
    b = [0]*N
    for i in range(N-1, -1, -1):
        if b[i] % MOD == a[i]:
            b[i] = 0
        else:
            b[i] = 1
            for d in make_divisors(i+1)[:-1]:
                b[d-1] += 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:
# coding: utf-8
# Your code here!

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

box = [0]*N

for i in range(N//2, 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, -1):
    #print(i)
    if func_k(i,i) != A[i]:
        box[i] = 1


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

Submission status: Wrong Answer

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

H = [0]*N
for i in range(N,0,-1):
#    print(i)

    if i > N/2:
        H[i-1] = A[i-1]
    else:
        sum = 0
        bai = 1
        while i*bai <= N:
            sum += A[(i*bai)-1]
            bai += 1
        if sum % 2 == 0:
            H[i-1] = 0
        else:
            H[i-1] = 1

M=0
out=[]
for h in H:
    if h == 1:
        M+=1
        out.append(h)
print(M)


for o in out:
    print(str(h)+" ",end='')

Submission status: Wrong Answer

Solution code:
import math
from collections import deque

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

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

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

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int,input().split()))
B=[0] * N
flag = False
for i in reversed(range(1, N+1)):
    a = A[i-1]
    for j in range(1, N+1):
        tmp = i * j
        if tmp > N:
            break
        a = (B[tmp-1] + a) % 2
    if a == 1:
        print(i)
        flag = True
    B[i-1] = a
if not flag:
    print(0)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
ok = True
for i in range(n):
  if a[i] == 1:
    for j in range(1,int(n/(i+1))):
      if a[(i+1)*j+i] == 1:
        ok = False
    else:
      continue
    break
if a.count(1) > n:
  ok = False
if ok == False:
  print(-1)
  exit()

if a.count(1) == 0:
  print("0")
  exit()
else:
  print(a.count(1))
  ans = [i+1 for i, x in enumerate(a) if x == 1]
  print(' '.join(map(str,ans)))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
ai = [int(x) for x in input().split()]
bn = [0] * n

for i in range(0,n):
    j = n - 1 - i
    c = 0
    for k in range(1, n):
        idx = k * (j + 1) - 1
        if  idx >= n-1:
            break
        c += bn[idx]
    
    bn[j] = (c + ai[j]) & 1


m = sum(bn)
print(m)
for i in range(0,n):
    if bn[i] == 1:
        print(i+1, end=" ")

Submission status: Wrong Answer

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

b=[0]*n
for i in range(n,0,-1):
    v=0
    for j in range(i,n+1,i):
        v+=b[j-1]
    b[i-1]=1 if v%2!=a[i-1] else 0
m=b.count(1)
print m
if m > 0:
    print "1 " * m

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int,input().split()))
B=[0] * N
flag = False
for i in reversed(range(1, N+1)):
    a = 0
    for j in range(1, N+1):
        tmp = i * j
        if tmp > N:
            break
        a = (B[tmp-1] + a) % 2
    if (A[i-1] + a) % 2 == 1:
        print(i)
        flag = True
    B[i-1] = a
if not flag:
    print(0)

Submission status: Wrong Answer

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

ball = [0] * N

for i in range(N-1, -1, -1) :
    bit = A[i]
    for j in range(i + 1, N) :
        bit = (bit + ball[i]) % 2
    ball[i] = bit % 2

print(*ball)

Submission status: Wrong Answer

Solution code:
n = int(input())
ai = [int(x) for x in input().split()]
bn = [0] * n

for i in range(0,n):
    j = n - 1 - i
    c = 0
    for k in range(1, n):
        idx = k * (j + 1) + 1
        if  idx >= n-1:
            break
        c += bn[idx]
    
    bn[j] = (c + ai[j]) & 1


m = sum(bn)
print(m)
for i in range(0,n):
    if bn[i] == 1:
        print(i+1, end=" ")

Submission status: Wrong Answer

Solution code:
import numpy as np
n = int(input())
a = [int(i) for i in input().split()] 
 
a = np.array(a)
ls = a
cnt = 0
arr = []

st = int(n/2)
for ind in range(st, 0, -1):
    tmp = list(range(2*ind-1, n, ind))
    s = ls[tmp].sum()%2
    if a[ind-1] == s:
        ls[ind-1] = 0
    else:
        cnt += 1
        arr.append(ind)
        ls[ind-1] = 1
        
print(cnt)
print(' '.join(map(str, arr)))

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int, input().split()))
res = [0] + a[:]
for i in reversed(range(N + 1)):
  if i == 0: continue
  res[i] = sum(res[i : : i]) % 2 
print(sum(res))
print(*[i for i in range(N) if res[i]])

Submission status: Wrong Answer

Solution code:
def yakusuu(n):
    yakusuu_list = list()
    for i in range(n):
        if n % i == 0:
            yakusuu_list.append(i)
    return yakusuu_list


def baisuu(n, max_N):
    baisuu_list = list()
    for i in range(n, max_N + 1, n):
        baisuu_list.append(i)
    return baisuu_list


N = int(input())
A = [-1] + list(map(int, input().split()))
box = [0 for _ in range(N + 1)]

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

for i in range(N // 2, 0, -1):
    baisuu_list = baisuu(i, N)
    baisuu_xor = 0
    for b in baisuu_list:
        baisuu_xor ^= box[b]
    box[i] = baisuu_xor ^ A[i]

print(" ".join(map(str, box[1:])))

Submission status: Wrong Answer

Solution code:
from math import log


def solve(A, N):
    B = [0] * len(A)
    for i in range(1, N+1)[::-1]:
        A2 = A[i*2] if i*2 <= N else 0
        #B2 = B[i*2] if i*2 <= N else 0
        B[i] = A[i] ^ A2
    return B

def main():
    N = int(input())
    A = [0] + [int(x) for x in input().split()]
    B = solve(A, N)
    print(sum(B))
    for i in range(1, N+1):
        if B[i]:
            print(i)

main()

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):
    word=a_list[i]
    k=i
    for j in range(2,N):
        if j*(i+1) < N:
            if box[j*(i+1)-1]==1:
                sum+=1
        else:
            break
    i=k
    if word == 0:
        if sum%2 == 1:
            box[i]=1
    else:
        if sum%2 == 0:
            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))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
ball = []
s = 0

for i in range(n-1, (n-1)//2, -1):
    ball.insert(0, a[i])
for i in range((n-1)//2, -1, -1):
    for j in range(len(ball)):
        if (j+1) % (i+1) == 0:
            s += ball[j]

    s = s % 2
    if a[i] == s:
        ball.insert(0, 0)
    else:
        ball.insert(0, 1)
ans = ""
for i in range(n):
    if ball[i] == 1:
        ans += " " + str(i+1)

if ans != "":
    print(ans)
else:
    print("0")

Submission status: Wrong Answer

Solution code:
n = int(input())
ai = [int(x) for x in input().split()]
bn = [0] * n

for i in range(0,n):
    j = n - 1 - i
    c = 0
    for k in range(1, n):
        if k * j + 1 >= n-1:
            break
        c += bn[j*k+1]
    
    bn[j] = (c + ai[j]) & 1


m = sum(bn)
print(m)
for i in range(0,n):
    if bn[i] == 1:
        print(i+1, end=" ")

Submission status: Wrong Answer

Solution code:

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

b = np.zeros((n))

for i in range(n):
    b[i] = a[i]

#print(b)

if n % 2 == 0:
    p = int(np.ceil(n/2))
else:
    p = int(np.ceil(n/2)-1)
#print(p)

for i in reversed(range(p+1)):

    ot_b = 0
    for j in reversed(range(1,int(n/(i+1)))):
        #print(i,j)
        ot_b += b[(i+1)*(j+1)-1]

    if (ot_b % 2) == a[i]:
        b[i] = 0
    else:
        b[i] = 1


b = b.astype(int)

#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',''))

else:
    print(-1)

Submission status: Wrong Answer

Solution code:
n= int(input())
A = list(map(int, input().split()))
B = [0]*(n+1)
B_sum = [0]*(n+1)
A_sum = sum(B)
count = 0
ans = False

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

    j = 1
    while i*j <= n:
        B_sum[i] += B[(i)*j]
        j += 1
    if B_sum[i] % 2 != A[i-1]:
        B[i] = 1
        count += 1
print(count)
for i in range(1,n+1):
    
    if B[i]==1:
        print(i, end = "")

Submission status: Wrong Answer

Solution code:
m = int(input())
b = list(map(int, input().split()))

for i in range(m//2,m//3,-1):
    if b[i-1] == b[i*2-1]:
        b[i-1] = 0
    else:
        b[i-1] = 1



for i in range(m//3,0,-1):
    suma = b[i*2-1]
    for ii in range(i*3-1,m,i*2):
        suma += b[ii]
    if b[i-1] == suma%2:
        b[i-1] = 0
    else:
        b[i-1] = 1

print(b.count(1))
c= []
for i in range(m):
    if b[i] == 1:
        c.append(str(i+1))

print(' '.join(c))

Submission status: Wrong Answer

Solution code:
n = int(input())
ai = [int(x) for x in input().split()]
bn = [0] * n

for i in range(0,n):
    j = n - 1 - i
    c = 0
    for k in range(1, n):
        if k * j >= n-1:
            break
        c += bn[j*k]
    
    bn[j] = (c + ai[j]) & 1


m = sum(bn)
print(m)
for i in range(0,n):
    if bn[i] == 1:
        print(i+1, end=" ")

Submission status: Wrong Answer

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

boxin = []
bx = [0 for _ in range(N+1)]
for cnt in range(N, 0, -1):
    a = ax[cnt-1]
    i = 2
    memo_cnt = 0
    while 1:
        test_val = i * cnt
        if test_val > N:
            break
        if bx[test_val]:
            memo_cnt += 1
        i += 1
    if a != memo_cnt % 2:
        boxin.append(cnt)

 
box = len(boxin)
print(box)
if box != 0:
    boxin.reverse()
    print(' '.join(map(str, boxin)))

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int, input().split()))
eo=[]
ans=[]
for i in range(n):
    k=eo[:i+1:n-i]
    if len(k) <= 1: eo.append(a[-(i+1)])
    else: eo.append((sum(eo)+a[n-i-1])%2)
    if eo[-1]==1: ans.append(n-i-1)
eo=eo[::-1]
print(eo.count(1))
print(*ans)

Submission status: Wrong Answer

Solution code:
import sys
import math

def add_ball(idx):
    add_list = [idx]
    if idx > 1:
        for j in range(2, int(math.sqrt(idx))+1):
            if idx%j == 0:
                add_list.append(j)
                if j != idx//j:
                    add_list.append(idx//j)
    for k in add_list:
        b_list[k-1] = (b_list[k-1]+1)%2

if __name__ == "__main__":
    input = sys.stdin.readline

    n = int(input())
    a_list = list(map(int, input().split()))
    b_list = [0] * n
    for i, a in enumerate(a_list[::-1]):
        if a != b_list[-i-1]:
            add_ball(n-i)
    ball_sum = sum(b_list)
    ball_list = [i+1 for i, b in enumerate(b_list) if b == 1]
    print(ball_sum)
    if ball_sum > 0:
        print(' '.join(map(str, ball_list)))

Submission status: Wrong Answer

Solution code:
N = int(input())
Atmp = [0] + list(map(int, input().split()))
A = {}

for i,a in enumerate(Atmp):
    A[i] = a

#print(A)

X = {}

for i in reversed(list(range(1,N+1))):
    Xsum = 0
    j = 2
    while(i*j < N):
        Xsum += X[i*j]
        j += 1
        continue
    odd = Xsum % 2
    if odd == A[i]:
        X[i] = 0
    else:
        X[i] = 1
    



def umeru(X, M, last):
    #print('---')
    for i in reversed(list(range(N//(M+1)+1, N//M+1))):
        if M == 1:
            X[i] = A[i]
        else:
            Xsum = 0
            j = 2
            while(i*j < N):
                Xsum += X[i*j]
                j += 1
                continue
            odd = Xsum % 2
            #print(M, i, odd, A[i])
            if odd == A[i]:
                X[i] = 0
            else:
                X[i] = 1
    #print(N,M,X)
    if last:
        return
    if N//(M+1) == 0:
        umeru(X, M+1, True)
    else:
        umeru(X, M+1, False)

#umeru(X, 1, False)
#print(X)

M = 0
for i in range(1, N+1):
    if X[i] == 1:
        M += 1

print(M)

for i in range(1, N+1):
    if X[i] == 1:
        print(i, end=' ')


print()

Submission status: Wrong Answer

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

ball = [0] * N
ball[-1] = A[-1]

for i in range(N-2, -1, -1) :
    bit = A[i]
    for j in range(i, N) :
        bit ^= ball[i]
    ball[i] = bit

print(*ball)

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int,input().split()))
flag = False
for i in reversed(range(1, N+1)):
    a = 0
    for j in range(1, N+1):
        tmp = i * j
        if tmp > N:
            break
        a = (A[tmp-1] + a) % 2
    if a == 1:
        print(i)
        flag = True
if not flag:
    print(0)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
A.insert(0, 0)
 
def get_index(n):
    return [i for i in range(2 * n, N + 1, n)]
  
def f():
    F = set()
    for n in range(N, 0, -1):
        index = get_index(n)
        # print(n, index)
        a = sum([A[i] for i in index]) % 2
        if a != A[n]:
            F.add(n)
 
    return F

F = f()
print(len(F))
if len(F) != 0:
  L = list(map(str, F))
  print(" ".join(L))

Submission status: Wrong Answer

Solution code:
import numpy as np


def acinput():
    return list(map(int, input().split(" ")))


N = int(input())
# N=10**5
# a=np.random.randint(0,2,N)
a = acinput()
a.insert(0,0)
tmp=[0 for i in range(N+1)]
b = np.array(tmp)

aaa=int(np.ceil(N/2))
for i in range(aaa,N+1):
    b[i] = a[i]

#print(b)
res = 0
for k in reversed(range(1, int(N/2)+1)):
#    print(k)
    r = np.arange(2*k, N+1, k)
    b[k] = (a[k]+np.sum(b[r])) % 2

#print("b",b)
res=[]
count=0
for k in range(1,N+1):
    if b[k]!=0:
        count+=1
        res.append(b[k])



print(count)
if count>0:
    print(" ".join(list(map(str,res))))

Submission status: Wrong Answer

Solution code:
from math import log


def solve(A, N):
    B = [0] * len(A)
    for i in range(1, N)[::-1]:
        A2 = A[i*2] if i*2 <= N else 0
        #B2 = B[i*2] if i*2 <= N else 0
        B[i] = A[i] ^ A2
    return B

def main():
    N = int(input())
    A = [0] + [int(x) for x in input().split()]
    B = solve(A, N)
    print(sum(B))
    for i in range(1, N+1):
        if B[i]:
            print(i)

main()

Submission status: Wrong Answer

Solution code:

n=int(input())
m=0
    
    
    
a=list(map(int,input().split()))
ans=[0 for i in range(n)]
b=[1]
a=b+a  

x=0
for i in reversed(range(1,n)):
        
        if(i*2>=n):
                ans[i]==a[i]
                if(a[i]==1):
                        m+=1
        
        elif(i*2<n):
                h=2
                while((i)*h<n):
                        e=i*h
                        x+=ans[e]
                        h+=1
            
                if(x%2!=a[i]):
                        x+=a[i]
                        if a[i]==1:
                                m+=1
                
                ans[i]=x
                x=0
        
    



print(m)
for i in range(n):

        print(str(ans[i])+" " if ans[i]==1 else "",end="")
print("")

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int, input().split()))
eo=[]
ans=[]
for i in range(n):
    k=eo[:i+1:n-i]
    if len(k) <= 1: eo.append(a[-(i+1)])
    else: eo.append((sum(eo)+a[n-i-1])%2)
    if eo[-1]==1: ans.append(i+1)
eo=eo[::-1]
print(eo.count(1))
print(*ans)

Submission status: Wrong Answer

Solution code:
n= int(input())
A = list(map(int, input().split()))
B = [0]*n
B_sum = [0]*n
A_sum = sum(B)
count = 0
ans = False

for i in range(n):

    j = 1
    while (n-i)*j <= n:
        B_sum[n-i-1] += B[(n-i-1)*j]
        j += 1
    if B_sum[n-i-1] % 2 != A[n-i-1]:
        B[n-i-1] = 1
        count += 1
print(count)
for i in range(n):
    
    if B[i]==1:
        print(str(i+1) + " ", end = "")

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, 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, -1):
    #print(i)
    if func_k(i,i) != A[i]:
        box[i] = 1



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

Submission status: Wrong Answer

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

if len(set(A)) == 1 and A[0] == 0:
  print(0)
else:
  flag=0
  ans = []
  start=N
  for n in range(N+1):
    end = start
    start = N // (n+1)
    if start == end:
      end+=1
    ans += [start+(i+1) for i, x in enumerate(A[start:end]) if x==flag]
    flag = 1 - flag
  print(len(ans))
  print(' '.join([str(n) for n in list(set(ans))]))

Submission status: Wrong Answer

Solution code:
N=int(input())
box=[1]*N
a_list=list(map(int,input().split()))
sum=0
for i in range(N-1,-1,-1):
    for j in range(1,N):
        if j*(i+1) <= N:
            if box[j*(i+1)-1]==1:
                sum+=1
        else:
            break
    if a_list[i] == 0:
        if sum%2 == 1:
            box[i]=0
    else:
        if sum%2 == 0:
            box[i]=0
    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))

Submission status: Wrong Answer

Solution code:
import numpy as np
n = int(input())
a = [int(i) for i in input().split()] 
 
a = np.array(a)
ls = a
st = int(n/2)
cnt=0
ans=[]

for ind in range(st, 0, -1):
    tmp = list(range(2*ind-1, n, ind))
    s = ls[tmp].sum()%2
    if a[ind-1] == s:
        ls[ind-1] = 0
    else:
        cnt+=1
        ans.append(ind)
        ls[ind-1] = 1
        
print(cnt)
if cnt>0:
    ans = map(str, ans)
    print(' '.join(ans))