Problem:


Score : 400 points

Problem Statement

There are N empty boxes arranged in a row from left to right.
The integer i is written on the i-th box from the left (1 \leq i \leq N).

For each of these boxes, Snuke can choose either to put a ball in it or to put nothing in it.

We say a set of choices to put a ball or not in the boxes is good when the following condition is satisfied:

For every integer i between 1 and N (inclusive), the total number of balls contained in the boxes with multiples of i written on them is congruent to a_i modulo 2.

Does there exist a good set of choices? If the answer is yes, find one good set of choices.

Constraints

All values in input are integers.

1 \leq N \leq 2 \times 10^5

a_i is 0 or 1.

Input

Input is given from Standard Input in the following format:

N
a_1 a_2 ... a_N

Output

If a good set of choices does not exist, print -1.

If a good set of choices exists, print one such set of choices in the following format:

M
b_1 b_2 ... b_M

where M denotes the number of boxes that will contain a ball, and b_1,\ b_2,\ ...,\ b_M are the integers written on these boxes, in any order.

Sample Input 1

3
1 0 0

Sample Output 1

1
1

Consider putting a ball only in the box with 1 written on it.

There are three boxes with multiples of 1 written on them: the boxes with 1, 2, and 3. The total number of balls contained in these boxes is 1.

There is only one box with a multiple of 2 written on it: the box with 2. The total number of balls contained in these boxes is 0.

There is only one box with a multiple of 3 written on it: the box with 3. The total number of balls contained in these boxes is 0.

Thus, the condition is satisfied, so this set of choices is good.

Sample Input 2

5
0 0 0 0 0

Sample Output 2

0

Putting nothing in the boxes can be a good set of choices.



Sample input:
3
1 0 0


Sample output:
1
1

Submission status: Wrong Answer

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

b = [ 0 for _ in range(N)]
for i in reversed(range(1, N+1)):
    summ = 0
    for j in range(i, N+1, i):
        summ += a[j-1]
    divs = summ % 2
    #print(divs)
    b[i-1] = divs

cnt = sum(b)
print(cnt)
if cnt > 0:
    for j in range(N):
        if b[j] == 1:
            print(j+1, end="")
    print()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
#ABC134 D

import sys
import math
import bisect
from heapq import heappush, heappop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
mod = 10**9 + 7

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

b = []

for i in range(n//2-1,n):
    if a[i] == 1:
        b.append(i+1)
for i in range(1,n//2)[::-1]:
    s = 0
    if i == 1:
        if len(b) == 0:
            break
        elif len(b) % 2 != a[0]:
            b.append(1)
            break
        else:
            break
    for j in b:
        if j % i == 0:
            s += 1
    if s % 2:
        b.append(i)

if len(b) == 0:
    if a[0] == 1:
        b.append(1)
    else:
        print(len(b))
        quit()
if len(b) != 0:
    b.sort()
    print(len(b))
    for i in range(len(b)-1):
        print(b[i],end=' ')
    print(b[-1])

Submission status: Wrong Answer

Solution code:
import numpy as np
N=int(input())
A=np.array(list(map(int,input().split())))
arr=[]
c=0
for i in range(0,N):
#     vec=np.zeros(N,dtype=bool)
#     vec[np.arange(i,N,i+1)]=True
#     print(np.arange(i,N,i+1))
    if sum(A[np.arange(i,N,i+1)])%2==A[i]:
        c+=1
        if A[i]==1:
            arr.extend([str(i+1)])
if c==N:    
    ans=len(arr)
    print(ans)
    if ans>0:
        print(" ".join(arr))
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
import sys
def input():
    return sys.stdin.readline()[:-1]
N = int(input())
A = list(map(int, input().split()))

chk = [0]*N

A.reverse()
for i, a in enumerate(A):
    if a == 0:
        continue
    else:
        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:
import numpy as np
from collections import defaultdict
from heapq import heappush, heappop
from math import ceil


def djkstra_adj_list(adj_list, src):
    dist = defaultdict(lambda: np.inf)
    dist[src] = 0

    prev = defaultdict(lambda: None)

    queue = []
    heappush(queue, (dist[src], src))

    while len(queue) > 0:
        dist_u, u = heappop(queue)
        vs = adj_list[u]
        for v, weight in vs:
            alt = dist_u + weight
            if alt < dist[v]:
                dist[v] = alt
                prev[v] = u
                heappush(queue, (alt, v))

    return dist, prev


def djkstra_adj_mat(adj_mat, src):
    dist = defaultdict(lambda: np.inf)
    dist[src] = 0

    prev = defaultdict(lambda: None)

    queue = []
    heappush(queue, (dist[src], src))

    while len(queue) > 0:
        dist_u, u = heappop(queue)
        vs = np.argwhere(adj_mat[u] > 0).flatten()
        for v in vs:
            weight = adj_mat[u, v]
            alt = dist_u + weight
            if alt < dist[v]:
                dist[v] = alt
                prev[v] = u
                heappush(queue, (alt, v))

    return dist, prev


def main():

    N = int(input())
    a_arr = list(map(int, input().split()))
    a_arr = np.array(a_arr, dtype=np.int)

    boxes = np.zeros(N, dtype=np.int)

    # boxes[N//2+1-1:] = a_arr[N//2+1-1:]

    # for i in range(N//2, 0, -1):
    #     boxes[i-1] = (np.sum([boxes[np.arange(i * 2, N+1, i)-1]]) + a_arr[i-1]) % 2

    n = N
    while n > 0:
        boxes[n//2:n] = a_arr[n//2:n]
        if n % 2 == 0:
            a_arr[:n//2] += a_arr[n//2:n]
        else:
            a_arr[:n//2] += a_arr[n//2:n-1]
        a_arr[:n//2] %= 2
        n = n//2

    M = int(np.sum(boxes == 1))
    print(M)
    j = 0
    b_arr = np.argwhere(boxes == 1)
    for j in range(M):
        if j == M - 1:
            print(int(b_arr[j]) + 1)
        else:
            print(int(b_arr[j]) + 1, end=' ')


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
n = int(input())
num = list(map(int, input().split()))
frag = 0
ans = []
def unchi(i, n):
    if i == n:
        buri = []
    else:
        buri = [i]
        j = i
        while j < n:
            j += i
            if j <= n:
                buri.append(j)
    return buri 

for i in range(len(num)-1, -1, -1):
    cnt = 0
    if(num[i] == 1):
        for j in unchi(i+1, len(num)):
            if(j in ans):
                cnt += 1
        if(cnt % 2 == 0):
            ans.append(i+1)

    else:
        for j in unchi(i+1, len(num)):
            if(j in ans):
                cnt += 1
        if(cnt % 2 == 1):
            ans.append(i+1)
ans.reverse()
print(len(ans))
if len(ans) >= 1:
    for i in range(len(ans)):
        sys.stdout.write(str(ans[i]) + " ")
else:
    print(0)

Submission status: Wrong Answer

Solution code:
n = int(input())
ai = list(map(int,input().split()))
ans = [0 for i in range(n)]

while n != 0:
  for i in range(int(n/2),n):#後半の処理
    ans[i] = ai[i]
    if ai[i] ==1:
      print()
      print(i)
      print()
      for j in range(int((i+1)/2)):#前半の処理
        print(j)
        if(i+1)%(j+1) ==0:
          ai[j] = 1 - ai[j]
  n = int(n/2)
if ai[0] == ans[0]:
  print(sum(ans))
  if (sum(ans) == 0):
    print(0)
    exit(0)
  else:
    for i in range(len(ans)):
      if(ans[i] == 1):
        print('{} '.format(i+1),end='')
else:
  print(-1)

Submission status: Wrong Answer

Solution code:
import math

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

for i in range(N):
	if i > N/2:
		if a[i]==1:
			print(1)
			print(i)
			break;
		else:
			print(-1)
			break;

	else:
		cnt = 0
		for j in range( int(math.floor(N/(i+1))) ):
			if a[i+i*j]==1:
				cnt += 1
				b.append(i+i*j+1)

		if cnt%2 == a[i]:
			print(cnt)
			for k in range(cnt):
				print(b[k])
			break;

		else:
			print(-1)
			break;

Submission status: Wrong Answer

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

for i in range(n):
    t = n - i - 1
    if i < n / 2:
        b[t] = a[t]
    else:
        to = 0
        j = 0
        while (t + 1) * j + (t + 1) < n:
            to += b[(t + 1) * j + (t + 1)]
            j += 1
        if to % 2 != a[t]:
            b[t] = 1

print(b.count(1))

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

Submission status: Wrong Answer

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


for i in range(N):
    j = N - i - 1
    #rint(j)
    b_ = box[::(j+1)]
    if (sum(b_)%2 == 0):
        if A[j] == 0:
            continue
        else:
            box[j] = 1
    else:
        if A[j] == 0:
            box[j] = 1
        else:
            continue


print(sum(box))
if sum(box) > 0:
    #s = " ".join([i for i in range(N) if box[i] == 1])
    s = " ".join([str(i+1) for i in range(N) if box[i] != 0])
    print(s)

Submission status: Wrong Answer

Solution code:
n = int(input())
arr = list(map(int, input().split()))
sol = [arr[i] for i in range(n)]

for i in range(n):
    sol[n-i-1] = sum(sol[n-i-1::n-i])

result = [sol[i]%2 for i in range(n)]
a = sum(result)
ls = ""
for i in range(n):
    if result[i] == 1:
        ls = ls + " " + str(i+1)

print(a)
if ls == "":
    print(str(0))
else:
    ls = ls[1:]
    print(ls)

Submission status: Wrong Answer

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

ball = [0] * N


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

for i in reversed(range(N)):
        tmp = 0
        if i != 0:
                for j in range(i + (i + 1), N, i + 1):
                        if (j + 1) % (i + 1) == 0:
                                tmp += a[j]
        else:
                tmp = sum(a[1:])
        if tmp % 2 != a[i]:
                ball[i] = 1

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

Submission status: Wrong Answer

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

n=int(input())
a=list(map(int,input().split()))
b=[2]*n

for i in range(n):
	if n-i in yakusu(n):
		cnt=0
		for k in range(n//(n-i)):
			if b[(n-i)*(k+1)-1]==1:
				cnt+=1
		if cnt%2==a[n-i-1]:
			b[n-i-1]=0
		else:
			b[n-i-1]=1
	else:
		b[n-i-1]=a[n-i-1]
ans_1=0
ans_2=[]
for i in range(n):
	if b[i]==1:
		ans_1+=1
		ans_2.append(i+1)
print(ans_1)
print(*ans_2)

Submission status: Wrong Answer

Solution code:
import math
N = int(input())
ax = list(map(int,input().split()))
def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]


def factorization(n,prime):
    arr = []
    temp = n
    for i in prime:
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])
    if arr==[]:
        arr.append([n, 1])

    return arr




boxin = []
half = math.ceil(1.0*N/2)
prime = primes(half)

memo = {}
for p in prime:
    memo[p] = 0

for cnt in range(N, 0, -1):
    a = ax[cnt-1]
    inflag = False
    if cnt >= half:
        if a == 1:
            boxin.append(cnt)
            inflag = True
    else:
        # 数値を素因数分解して倍数を探す
        soinsu = factorization(cnt, prime)
        baisu = []
        for p, cnt in soinsu:
            if p != 1:
                baisu.append([p**cnt, memo[p]//cnt])
        # 倍数の個数を確定させる
        baisu_cnt = len(baisu)
        if baisu_cnt == 0:
            memo_cnt = len(boxin)
        elif baisu_cnt == 1:
            memo_cnt = baisu[0][1]
        else:
            b = 1
            for i in range(1,baisu_cnt):
                b *= baisu[i][0]
            memo_cnt = baisu[0][1] // b
        if memo_cnt % 2 != a:
            boxin.append(cnt)
            inflag = True
        
    if inflag:
        # 素数で割り切れるか確認する
        for p in prime:
            if p >= cnt // 2:
                if cnt % p == 0:
                    memo[p] += 1
            else:
                break
    
box = len(boxin)
print(box)
if box != 0:
    boxin.reverse()
    print(' '.join(map(str, boxin)))

Submission status: Wrong Answer

Solution code:
import math

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

for i in range(N):
	if i > N/2:
		if a[i]==1:
			print(1)
			print(i)
			break;
		else:
			print(-1)
			break;

	else:
		cnt = 0
		for j in range( int(math.floor(N/(i+1))) + 1 ):
			if a[i+i*j]==1:
				cnt += 1
				b.append(i+i*j+1)

		if cnt%2 == a[i]:
			print(cnt)
			for k in range(cnt):
				print(b[k])
			break;

		else:
			print(-1)
			break;

Submission status: Wrong Answer

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


for i in range(N):
    j = N - i - 1
    #rint(j)
    b_ = box[::(j+1)]
    if (sum(b_)%2 == 0):
        if A[j] == 0:
            continue
        else:
            box[j] = 1
    else:
        if A[j] == 0:
            box[j] = 1
        else:
            continue


print(sum(box))
if sum(box) > 0:
    #s = " ".join([i for i in range(N) if box[i] == 1])
    s = " ".join([str(i+1) for i in range(N) if box[i] != 0])
    print(s)
else:
    print(0)

Submission status: Wrong Answer

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

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

ans = sum(A)
print(A)
print(ans)
if ans > 0:
    print(*[i+1 for i, a in enumerate(A) if a == 1], sep=" ")

Submission status: Wrong Answer

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

b = [0] * N
i = N-1
while i >= 0:
    for j in range(N//(i+1)):
        c[i] = c[i] - b[j]
    b[i] = c[i]%2
    i -= 1


count = 0
for i in range(N):
    e = sum(a[i::i+1])
    if e%2 != a[i] :
        print(-1)
        count =1
        break


if count == 0 :
    d = []

    print(b.count(1))

    for i in range(N):
        if b[i] ==1 :
            d.append(str(i+1))

    if len(d) != 0:
        print(' '.join(d))

Submission status: Wrong Answer

Solution code:
n = int(input())

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

c = [0] * n
b = []

for i in range(n-1, -1, -1):
    c[i] = a[i] + 2
    if i ==  0:
        for j in range(1, n):
            c[i] -= c[j]
    elif n//i > 1:
        for j in range(1, n//i-1):
            c[i] -= c[i*(j+1)]
    c[i] = c[i] % 2
    if c[i] == 1:
        b.append(i+1)

m = len(b)

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

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
N = int(input())
a = []
b = []
n = 0
a = list(map(int,input().split()))

if a[0] == 0:
    print(0)
    exit(0)

for i in range(1, N):
    if a[i] == 1:
        b.append(set((range(2, N+1, i + 1))))
        n = n + 1
        
c = {1}        
for i in range(0, n-1):
    c = b[i] & b[i+1] 
    

print(len(c))
s = "" + str(c.pop())
for i in range(len(c)-1):
    s += " " + str(c.pop())

print(s)

Submission status: Wrong Answer

Solution code:
N = int(input())
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

cnt = 0
ans = [0] * (N+1)
digits = [0] * (N+1)
for i in range(N,0,-1):
    ans[i] = digits[i]%2 ^ A[i-1]
    cnt += ans[i]
    divs = make_divisors(i)
    for div in divs:
        digits[div] += ans[i]
    
# print(digits)
# print(ans)
print(cnt)
for a in ans[1:]:
    if cnt <= 0:
        break
    print(a)
    cnt -= a

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
m=0
b=[0]*n
for i in reversed(range(n)):
    num=int(n/(i+1))
    #print("["+str(num)+"]")
    if num==1:
        if a[i]==1:
            b[i]=1
            m+=1
    else:
        sum=0
        for j in range(num):
            sum+=b[i*(j+1)]
        sum%=2
        if a[i]==1:
            b[i]=1-sum
            m+=1-sum
        else:
            b[i]=sum
            m+=sum
        
print(m)
if(m!=-1):
    for i in range(n):
        if b[i]!=0:
            print((i+1),end=" ")
        print("")

Submission status: Wrong Answer

Solution code:
import math

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

flag = 0
s = sum(a)
if s == 0:
    print("0")
    exit()

for i in range(N, 0, -1):
    i_max = math.floor(N / i)

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


        if tmp % 2 == a[i]:
            l[i] = 0
        else:
            l[i] = 1

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

Submission status: Wrong Answer

Solution code:
import numpy as np
n=int(input())
a=np.array( [int(i) for i in input().split()])
b=np.array([99]*n)
for i in range(n//2,n):
    b[i]=a[i]
for i in range(n//2,0,-1):        
    cand = np.array([i*j for j in range(2,n//i+1)])
    if sum(a[cand-1])%2==0:
        b[i-1]=a[i-1]
    else:
        b[i-1]=1-a[i-1]

posi=np.where(b==1)[0]
print(len(posi))
for j in range(len(posi)):
    print(posi[j]+1,end=" ")

Submission status: Wrong Answer

Solution code:
# from sys import exit, stderr
# from inspect import currentframe
# def debug(*args):
#     names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}
#     print(', '.join(names.get(id(arg),'???')+' = '+repr(arg) for arg in args), file=stderr)
#     return
N = int(input())
a = [int(_) for _ in input().split()]
b = set()
out = []
n = 0
for i in range(N-1, -1, -1):
    if a[i] == 1:
        tmp = 1
        for e in out:
            tmp *= e
            if e%(i+1) == 0:
                a[i] = 0 if a[i] else 1
        while((tmp+1)%(i+1) != 0):
            tmp += 1
        out.append(tmp + 1)
        a[i] = 0
        n += 1
    b.add(i+1)
print(n)
if len(out) > 0:
    for i in range(len(out)):
        print(out[i], end=" ")
    print()

Submission status: Wrong Answer

Solution code:
N = int(input())
a = [int(x) for x in input().split()]
b = [0]*N
for i in range(N):
    if a[N-i-1] != sum([b[x] for x in range(N-i-1,N,N-i)]) % 2:
        b[N-i-1] = 1
print(b.count(1))
if b.count(1) != 0:
    print(" ".join([str(x+1) for x in b if x==1]))

Submission status: Wrong Answer

Solution code:
def primes(x):
  is_prime = [True] * (x + 1)
  is_prime[0] = False
  is_prime[1] = False
  for i in range(2, int(x**0.5) + 1):
    if not is_prime[i]:
      continue
    for j in range(i * 2, x + 1, i):
      is_prime[j] = False
  return [i for i in range(x + 1) if is_prime[i]]

n=int(input())
P=primes(n)
pp=len(P)
A=[int(i) for i in input().split()]
Ans=[]

for i in reversed(range(n)):
  if A[i]==1:    
    if 2*(i+1)>n:
      Ans.append(i+1)
      
    else:
      c=1
      j=0
      while j<pp and P[j]*(i+1)<=n:
        if A[P[j]*(i+1)-1]==1:
          c^=1
        j+=1
      if c==1:
        Ans.append(i+1)
        
  elif A[i]==0:    
    c=0
    j=0
    while j<pp and P[j]*(i+1)<=n:
      if A[P[j]*(i+1)-1]==1:
        c^=1
      j+=1
    if c==1:
      Ans.append(i+1)
      
if len(Ans)==0:
  print(0)
else:
  print(len(Ans))
  Ans.sort()
  print(*Ans)

Submission status: Wrong Answer

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

n=int(input())
a=[int(i) for i in input().split()]
ans=[0]*n
for i in range(n-1,-1,-1):
    if a[i]==1:
        chk=0
        for j in range(2,n+1):
            if (i+1)*j<=n and a[(i+1)*j-1]:
                chk+=1
        if chk%2==0:
            ans[i]=1
print(n)
print(*ans)

Submission status: Wrong Answer

Solution code:
def printl(a,b):
    l=[0 for i in range(b)]
    for i in a:
        l[i-1]=1
    for i in l:
        print(i,end=" ")
    print()
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append(i)
            for j in range(0,cnt):
                arr.append(i**j)
    arr.append(temp)
    arr.append(n)
    return arr
n=input()
n=int(n)
a=[int(i) for i in input().split()]
a2=[i for i in a]
l=[0 for i in range(n)]
ll=[]
if 1 in a:
    of=0
    for i in reversed(a):
        if i==1:
            if (n-of)//n>1:
                x=factorization((n-of)*(n-of)//n)
                for j in x:
                    l[j-1]+=1
                    a[j-1]=0
                ll.append(n-of)
            else:
                x=factorization(n-of)
                for j in x:
                    l[j-1]+=1
                    a[j-1]=0
                ll.append(n-of)
        of+=1
    l=[i%2 for i in l]
    if l==a2:
        print(len(ll))
        printl(ll,n)
    else:
        print(-1)
                
else:
    print(0)

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):
    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 == 0:
            box[i]=0
    else:
        if sum%2 == 1:
            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:
N=int(input())

l=list(map(int,input().split()))
l=[0]+l
L=[0 for i in range(N+1)]
A=[]
for i in range(1,N+1):
    if l[N+1-i]==1:
        for j in range(2,10**5):
            if (N+1-i)*j>N:
                break
            else:
                if l[(N+1-i)*j]==1:
                    L[(N+1-i)]+=1
        if L[N+1-i]%2==0:
            L[N+1-i]+=1
            A.append(N+1-i)
A.sort()
print(len(A))
print(*A)

Submission status: Wrong Answer

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

flag = -1
counter = 0

while(True):
    if counter == N // 2:
        break

    total = sum(A[i] for i in range(counter, N, counter+1))
    if total % 2 == A[counter]:
        flag = counter + 1
        break
    
    counter += 1


if flag != -1:
    res = [str(i+1) for i in range(counter, N, counter+1) if A[i] == 1]
    print(len(res))
    if len(res) != 0:
        print(' '.join(res))
else:
    for i in range(counter, N):
        if A[i] == 1:
            flag = i
            print(1)
            print(A[i])
            break

if flag == -1:
    print(flag)

Submission status: Wrong Answer

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

b=[-1]*N
b[N-1]=a[N-1]
for i in range(N-1)[::-1]: #N=4なら 2,1,0
    sum_count = N // (i+1)
    if sum_count==1:
        b[i]=a[i]
    else:
        sum1=0
        for j in range(sum_count-1):
            sum1 = sum1 + b[(i+1)*(j+1)]
        sum1 = sum1 % 2
        b[i]=(a[i]+ sum1)%2

print(sum(b))
f=0
for i in range(N):
    if b[i]==1 and f==0:
        f=1
        out=str(i+1)
    elif b[i]==1:
        out = out + " " + str(i+1)
if f==1:
    print(out)

Submission status: Wrong Answer

Solution code:
import sys
def input():
    return sys.stdin.readline()[:-1]
N = int(input())
A = list(map(int, input().split()))

chk = [0]*N

A.reverse()
for i, a in enumerate(A):
    if a == 0:
        continue
    elif a == 1:
        chk[N-i-1] = 1
        continue
    else:
        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 = [int(x) for x in input().split()]
b = [0]*N
for i in range(N):
    if a[N-i-1] != sum([b[x] for x in range(N-i-1,N,N-i)]) % 2:
        b[N-i-1] = 1
print(b.count(1))
if b.count(1) != 0:
    print(" ".join(["1" for x in b if x==1]))

Submission status: Wrong Answer

Solution code:
import heapq as hq
def main():
    n = int(input())
    a = list(map(int,input().split(' ')))
    sep = (n**0.5//1)
    ans = []
    ans_sum = 0
    for num,i in enumerate(a[::-1]):
        if n-num > sep and i:
            ans.append(n-num)
            ans_sum += 1
        else:
            cnt = 0
            for j in ans:
                if not j%(n-num):
                    cnt += 1
            if cnt%2 != i:
                ans.append(n-num)
                ans_sum +=1
    print(ans_sum)
    for i in ans[::-1]:
        print(i,end='')
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n = int(input())
A = [int(i) for i in input().split()]

balls = list()
# for i, a in enumerate(reversed(A)):
for bn in range(n, 0, -1):
    a = A[bn - 1]
    if 2*bn > n:
        if a == 1:
            balls.append(str(bn))
    else:
        a2 = A[2*bn - 1]
        if a != a2:
            balls.append(str(bn))

print(len(balls))
print(' '.join(balls))

Submission status: Wrong Answer

Solution code:
def main():
    n = int(input())
    a_s = list(map(int, input().split(' ')))
    results = []
    for i, a in enumerate(a_s):
        if sum(a_s[i::(i+1)]) % 2 != a:
            print(-1)
            quit()
        if a == 1:
            results.append(str(i+1))
    print(len(results))
    if results:
        print(' '.join(results))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

result = []
res_ap = result.append

for i in range(N // 2, N)[::-1]:
    if a[i] == 1:
        res_ap(i)
for i in range(N // 2)[::-1]:
    j = 2 * (i + 1)
    while(j < N + 1):
        cnt = 0
        cnt += a[j - 1]
        j += i + 1
    if a[i] + cnt % 2 == 1:
        res_ap(i)
M = len(result)
print(M)
result.sort()
if M != 0:
    print(result[0] + 1, end = "")
    for i in range(1, M):
        print(" " + str(result[i] + 1), end = "")

Submission status: Wrong Answer

Solution code:
n=int(input())
al=list(map(int,input().split()))
ac=0
ans=set()
tl=[0]*n
for i in range(n,0,-1):
    if tl[i-1]%2!=al[i-1]:
        ac+=1
        ans.add(i)
        for j in range(1,int(i**0.5)+1):
            if i%j==0:
                tl[j-1]+=1
print(ac)
if ac>0:
    print(' '.join(map(str,ans)))

Submission status: Wrong Answer

Solution code:
N=int(input())
a =list(map(int, input().split()))
b=[]
c=[]
for x in range(N):
    b.append(0)
for z in range(0,N-1):
    if z!=0:
        a=b
    for x in range(1,N+1):
        X=0
        for y in range(1,N+1):
            if y%x==0 and a[y-1]==1:
                X=X+1
        b[x-1]=X%2
print(b.count(1))
if b.count(1)!=0:
    for x in range(N):
        if b[x]==1:
            c.append(x+1)
    L=[str(k) for k in c]
    L=" ".join(L)
    print(L)

Submission status: Wrong Answer

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

ans_lis = []

if sum(A) % 2 == 1:
    ans_lis.append(1)

for n in range(1, N):
    lis = A[n: :n + 1]
    if sum(lis) % 2 == A[n]:
        if A[n] == 1:
            ans_lis.append(n + 1)
    else:
        print(-1)
        sys.exit()
print(len(ans_lis))
print(' '.join(map(str, ans_lis)))

Submission status: Wrong Answer

Solution code:
import math

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

for i in range(N):
	if i > N/2:
		if a[i]==1:
			print(1)
			print(i)
			break;
		else:
			print(-1)
			break;

	else:
		cnt = 0
		for j in range(int(math.floor(N/(i+1)))):
			if a[(i+1)*j]==1:
				cnt += 1
				b.append((i+1)*j+1)

		if cnt%2 == a[i]:
			print(cnt)
			for k in range(cnt):
				print(b[k])
			break;

		else:
			print(-1)
			break;

Submission status: Wrong Answer

Solution code:
n = int(input())
arr = list(map(int, input().split()))
sol = [arr[i] for i in range(n)]

for i in range(n):
    sol[n-i-1] = sum(sol[n-i-1::n-i])

result = [sol[i]%2 for i in range(n)]
a = sum(result)
ls = ""
for i in range(n):
    if result[i] == 1:
        ls = ls + " " + str(i)

print(a)
if ls == "":
    print(str(0))
else:
    ls = ls[1:]
    print(ls)

Submission status: Wrong Answer

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

    count = 0  
    printlist = []

    count = 0
    printlist = []
    for i in range(N//2,N):
        boxes[i] = A[i]
        if A[i] == 1:
            count = 1
            printlist.append(i)
    for i in range(0,N//2):
        s = A[i]
        #print('i=',i)
        for j in range(2,N//(i+1)+1):
            #print('idx=',(i+1)*j - 1)
            s ^= boxes[(i+1)*j - 1]
        boxes[i] = s
        if s == 1:
            count += 1

            printlist.append(i)

    import sys
    print(count)
    for i in printlist:
        sys.stdout.write(str(i+1))
        sys.stdout.write(' ')

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#from sympy import *
#solve([x * y * z], [x, y, z])

n = int(input())
lst = list(map(int, input().split()))
#vals = [Symbol("x"+str(i))for i in range(n)]
#vals2 = []
for i in range(1, n+1):
  lsum = 0
  for j in range(i, n+1, i):
    lsum += lst[j-1]
  ans = 0
  if lsum%2 != lst[i-1]:
    ans = -1
    break
if ans == -1:
  print(ans)
else:
  print(sum(lst))
  print(" ".join(list(map(str, filter(lambda x:x==1,lst)))))

Submission status: Wrong Answer

Solution code:
import math

N = int(input())

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

bb = aa[:]

i = math.floor(N / 2) - 1

while i >= 0:
    bai = (i + 1) * 2 - 1
    if aa[i] == 1:  # 自分が奇数
        if aa[bai] == 0:  # 2倍が偶数
            bb[i] = 1
        else:  # 2倍が奇数
            bb[i] = 0
    else:  # 自分が偶数
        if aa[bai] == 0:  # 2倍が偶数
            bb[i] = 0
        else:  # 2倍が奇数
            bb[i] = 1
    i -= 1

bbKisu = filter(lambda n: n % 2 == 1, bb)
count = len(list(bbKisu))

print(count)
for i in range(N):
    if bb[i] == 1:
        print(i + 1)

Submission status: Wrong Answer

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

res = [0 for i in range(N)]
for i in range(N, 0, -1):
    othors_idxs = [j*i for j in range(int(N/i)) if j != 0]
    othors = [res[idx] for idx in othors_idxs]
    if sum(othors + [1]) % 2 == A[i-1]:
        res[i-1] = 1

ans = [str(i+1) for i in range(N) if res[i] == 1]
l = len(ans)
if l > 0:
    print(l)
    print(' '.join(ans))
else:
    print(0)

Submission status: Wrong Answer

Solution code:
from sys import stdin

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

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

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

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
print "1 " * m