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

flag = -1
counter = 0
total = 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

if flag != -1:
    res = [str(A[i]) 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 = [0]*N
for i, a in enumerate(A[::-1]):
    if N - i > N // 2:
        B[-(i+1)] = 1 if a == 1 else 0
    else:
        x = N-1
        n = 2
        c = 0
        while N >= x*n:
            if B[x*n-1] == 1:
                c += 1
            n += 1
        if c % 2 == 1:
            B[-(i + 1)] = 0 if a == 1 else 1
        else:
            B[-(i + 1)] = 1 if a == 1 else 0

print(B)

Submission status: Wrong Answer

Solution code:
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N = int(input())
A = list(map(int, input().split()))
put = []

for i in reversed(range(N)):
    if A[i] == 1:
        put.append(i+1)
        # iを素因数分解して、約数に1をxorしていく
        if i != 0:
            A[0] ^= 1
        tmp = 2
        n = i+1
        while tmp*tmp <= n:
            if n % tmp == 0:
                A[tmp-1] ^= 1
            tmp += 1

        for tmp in range(2, n):
            if n % tmp == 0:
                A[tmp-1] ^= 1

if len(put) > 0:
    print(len(put))
    print(*put)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
N=int(input())
a= list(map(int, input().split()))
n=N//2
b=[None]*N
for i in range(n,N):
        b[i]=a[i]
for i in range(n-1,0,-1):
        c=0
        t=i
        while t<N:
                if b[t]==1:
                        c+=1
                t+=i+1
        b[i]=c%2
M=b.count(1)
if a[0]==0:
        b[0]=M%2
        print(M)
else:
        b[0]=M%2+1
        print(M+1)
for i in range(N):
        if b[i]==1:
                print(i+1,end=" ")

Submission status: Wrong Answer

Solution code:
import logging

logging.basicConfig(level=logging.INFO, format="%(message)s")
#logging.disable(logging.CRITICAL)

def main():
    N = int(input())
    a_ = list(map(int, input().split()))
    box = [0 for _ in range(N)]

    logging.info("Hello!")

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

    for i in range(half_N):
        box_num = half_N - i

        sum = 0
        for j in range((N // (box_num)) - 1):
            sum += a_[(box_num) * (j + 2) - 1]

        box[box_num - 1] = abs(a_[box_num - 1] - (sum % 2))

    logging.info(box)

    print(box.count(1))
    for i in range(N):
        if box[i] == 1:
            print(i + 1)
            
    
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

result = []
for i in range(N):
    if a[i] == 1:
        result.append(i + 1)
M = len(result)
print(M)
for i in range(M):
    print(result[i])

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
ans = [0 for _ in range(N)]

for i, a in enumerate(A[::-1]):
    ind = N - i
    if ind > N//2:
        ans[ind-1] = a
    else:
        cnt = 0
        for j in range(2, (N // ind) + 1):
            cnt += A[j * ind - 1]
        if cnt % 2 == A[ind-1]:
            ans[ind-1] = 0
        else:
            ans[ind-1] = 1

print(sum(ans))
for i, a in enumerate(ans):
    if a == 1:
        print(i+1, end="")
        print(' ', end="")

Submission status: Wrong Answer

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

print('-1')

Submission status: Wrong Answer

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

#n ... 番目の箱　b[n-1]　のボールの数
blist = []
for j in range(n-1,-1,-1):
    if a[j] == 1:
        k=j+1
        count= 0
        while k<=n:
            count = count + b[k-1]
            k = k+j+1
        if count%2 == 0:
            b[j] = 1
            blist.append(j+1)

print(sum(b))
strb = " ".join(map(str,blist))
print(strb)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
input = sys.stdin.readline

##### リストの 二分木検索 #####
# bisect_left(lists, 3)
# bisect_right(lists, 3)

##### プライオリティキュー #####
# heapq.heapify(a) #リストaのheap化
# heapq.heappush(a,x) #heap化されたリストaに要素xを追加
# heapq.heappop(a) #heap化されたリストaから最小値を削除＆その最小値を出力

# heapq.heappush(a, -x) #最大値を取り出す時は、pushする時にマイナスにして入れよう
# heapq.heappop(a) * (-1) #取り出す時は、-1を掛けて取り出すこと

##### タプルリストのソート #####
# sorted(ans) #(a, b) -> 1st : aの昇順, 2nd : bの昇順
# sorted(SP, key=lambda x:(x[0],-x[1])) #(a, b) -> 1st : aの昇順, 2nd : bの降順
# sorted(SP, key=lambda x:(-x[0],x[1])) #(a, b) -> 1st : aの降順, 2nd : bの昇順
# sorted(SP, key=lambda x:(-x[0],-x[1])) #(a, b) -> 1st : aの降順, 2nd : bの降順

# sorted(SP, key=lambda x:(x[1])) #(a, b) -> 1st : bの昇順
# sorted(SP, key=lambda x:(-x[1])) #(a, b) -> 1st : bの降順

def main():

	N = int(input())
	# = list(input())
	#L,R = map(int, input().split(" "))
	#L = list(map(int, input().split(" ")))
	A = input().split()
	A = [int(s) for s in A]
	#P = getPrimeNumList(200000)

	ans = []
	hafe = N//2
	for i in range(N, 0, -1):
		if i > hafe:
			if A[i-1] == 1:
				ans.append(i)
			continue

		if A[i-1] != A[(i*2)-1]:
			ans.append(i)

	print(len(ans))
	if len(ans) != 0:
		ans2 = ""
		for i in reversed(ans):
			ans2 = ans2 + str(i) + " "

		print(ans2[:-1])

def getPrimeNumList(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]]

if __name__ == "__main__":
	main()

Submission status: Wrong Answer

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

n = INT()
a = LIST()
wa = []

L = []

for i in range(1, n+1):
    l = []
    j = 0
    while(i * j <= n):
        j += 1
        if i * j <= n:
            l.append(i * j)
    L.append(l)
# print(L)
sum_l = []
for i in range(n):
    sum_num = 0

    for baisu in L[i]:
        sum_num += a[baisu-1]
    sum_l.append(sum_num)
    # print(sum)

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

Submission status: Wrong Answer

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

primes = []
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:
            prime = num
            primes.append(num)
        else:
            cnt = 0
            for prime in primes:
                if prime%num==0:
                    cnt+=1
                    if cnt>1:
                        print('-1')
                        exit()
            if cnt==0:
                primes.append(num)

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

Submission status: Wrong Answer

Solution code:
n = int(input())

a = []
aa = input().split() 

for i in range(n):
    a.append(int(aa[i]))

ans = [0 for i in range(n)]

memo = int(n/2)+2
for i in range(n-1,-1,-1):
    if i >= memo:
        ans[i] = a[i]
    else:
        memo2 = 0
        s = i+1
        t = 2
        while (s*t-1)<=(n-1):
            if a[s*t-1] == 1:
                memo2 += 1
            t += 1
        if a[i] != memo2%2:
                ans[i] = 1

v = 0
for i in range(n):
    if ans[i] == 1:
        v += 1

print(v)

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

Submission status: Wrong Answer

Solution code:
N = int(input())

a = list(map(int, input().split()))
b = [0] * N
flag = True
for k in range(N):
    i = N - k
    count = 0
    for m in range(i, N, i):
        count += b[m]
    t = count % 2
    absv = a[i - 1] - count
    if absv == 0:
        pass
    elif absv == 1:
        b[i - 1] = 1
    else:
        print(-1)
        flag = False
        break

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

Submission status: Wrong Answer

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

    # divisors.sort()
    return divisors

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

for i in [i for i in range(1, N+1)][::-1]:
    x = a[i - 1]
    list_div = make_divisors(i)
    if x:
        for j in list_div:
            b[j - 1] = not b[j - 1]

c = sum(b)
print(c)

d = []
if c:
    for i, _ in enumerate(b):
        if _:
            d.append(i + 1)
    print(*d)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N=int(input())
a=list(map(int,input().split()))
M=0
b=[]
c=[]
for i in range(N):
    b.append(0)

for i in range(N-1,-1,-1):
    s=0
    for j in range(N//(i+1)):
        s+=b[(j+1)*(i+1)-1]
    if s//2!=a[i]:
        b[i]=abs(b[i]-1)

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

print(M)
print(' '.join(c))

Submission status: Wrong Answer

Solution code:
N = int(input())
aArr = list(map(int, input().split()))
tmpArr = [0] * len(aArr)
ansArr = []
for i in range(len(aArr) - 1, -1, -1):
    tmp = aArr[i]
    if i == 0:
        s = tmpArr
    else:
        s = tmpArr[::i]
    su = sum(s)
    if su % 2 != tmp:
        tmpArr[i] = 1
        ansArr.append(i+1)
print(sum(tmpArr))
print(" ".join(map(str,ansArr)))

Submission status: Wrong Answer

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

res = [0]

for i in b_list[::-1]:
    if sum(res) % 2 == i:
        res.append(0)
    else:
        res.append(1)

print(sum(res))
del res[0]

for idx, i in enumerate(reversed(res)):
    if i == 1:
        print(idx+1, end=' ')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
ans = []
half = n//2
half_ = n-half
for i in range(half):
    if a[n-i-1] == 1:
        ans.append(n-i)
for i in range(half_):
    x = n-half-i
    y = 0
    for j in range(n):
        if x*(j+2) <= n:
            if a[x*(j+2)-1] == 1:
                y += a[x*(j+2)-1]
        else:
            break
    ymod = y%2
    if not ymod == a[x-1]:
        ans.append(x)
s = len(ans)
print(s)
if s > 0:
    print(" ".join([str(i) for i in ans]))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys,math,copy
input = sys.stdin.readline

N=int(input().strip())
An=[int(x) for x in input().strip().split()]
Bn=[-1 for _ in range(N)]
Sum=0
for i in range(N-1,-1,-1):
    temp=0
    c=2
    index=(i+1)*c
    while index <= N:
        temp=temp^An[index-1]
        c+=1
        index+=(i+1)

    ball= An[i] ^ temp
    Sum+=ball
    Bn[i]= ball

print(Sum)
if Sum!=0:
    ans=[str(x+1) for x in range(N) if Bn[x]==1]
    print(' '.join(ans))

Submission status: Wrong Answer

Solution code:
n = int(input())
figure = list(map(int, input().split()))
one = []
error = 0#０だと正常

for i in range(n):
  if figure[i] == 1:
    one.append(i)
cnt_max = len(one)

for x in reversed(one):
  a = 0
  for i in range(x,n,x+1):
    if figure[i] == 1:
      a +=1
  if figure[x] != a%2:
    error += 1
    print("-1")
    break
if error == 0:
  data = list(map(lambda x:x+1, one))
  if not data:
    print("0")
  else:
    print(*data)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int,input().split()))
total = sum(a)
if total%2 == 0 and a[0] == 1:
    print(-1)
    exit()
elif total%2 == 1 and a[0] == 0:
    print(-1)
    exit()
b = []
counter = 0
for i in range(N-1,-1,-1):
    n = i+1
    total = 0
    for j in range(n,N+1,n):
        total += a[j-1]
    if total%2 == 0 and a[i] == 0:
        pass
    elif total%2 == 1 and a[i] == 1:
        counter += 1
        b.append(n)
    else:
        print(-1)
        exit()
if counter == 0:
    print(counter)
else:
    b.sort()
    print(counter)
    print(*b, sep=" ")

Submission status: Wrong Answer

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

ans=[0]*n

i=n-1
j=1
f=0
while i!=-1:
    while True:
        try:
            b=i+(i+1)*j
            f+=ans[b]
            j+=1
        except:
            break
    f=f%2
    if (f-s[i])==0:
        ans[i]=0
    else:
        ans[i]=1
    i-=1

print(ans.count(1))
i=0
while i!=len(s):
    if ans[i]==0:
        del s[i]
        del ans[i]
    else:
        i+=1


print(' '.join(map(str, ans)))

Submission status: Wrong Answer

Solution code:
import numpy as np
import math

N = int(input())
A = input().split(' ')

an = np.array(A, dtype=np.int64)

M = 0
b = []

for i in range(1,N):
   chk_num = int(N/(i))

   if(chk_num<2):
      continue

   ball = 0
   for j in range(1,chk_num):
      c = i * j
      ball += an[j]
   M += 1
   b.append((ball+1)%2)


print(M)
print(*b)

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:
      for j in range(int(n/2)):#前半の処理
        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:
N = int(input())
a = [int(i) for i in input().split()]


def input(p):
    s = 0
    for i in range(N):
        if i+1 % p == 0:
            s += a[i]
    return s


b = []
for i in range(1, N + 1):
    if input(i) % 2 != a[i-1]:
        print("-1")
        exit()
    if a[i-1] == 1:
        b.append(i)

M = sum(b)
print(M)
ans = ' '.join(map(str, b))
print(ans)

Submission status: Wrong Answer

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

for i in range(N, 0, -1):
    if sum(box[i-1::i]) % 2 != A[i-1]:
        box[i-1] = 1
        count+=1
        if ans:
            ans += " " + str(i)
        else:
            ans = str(i)

print(count)
if ans:
    print(ans)
else:
    print(0)

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)

    if temp!=1:
        arr.append(temp)

    if arr==[]:
        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:
            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())
L=[0 for i in range(n+1)]
a=list(map(int,input().split()))
for i in range((n//2)+1,n+1):
  L[i]=a[i-1]
  if L[i]==1:
    for j in range(1,int(i**0.5)+1):
      if i%j==0:
        L[j]+=1
        if j*j!=i and j!=1:
          L[i//j]+=1
for i in range(n//2,0,-1):
  L[i]=(a[i-1]+L[i])%2
  if i!=1 and L[i]==1:
    for j in range(1,int(i**0.5)+1):
      if i%j==0:
        L[j]+=1
        if j*j!=i and j!=1:
          L[i//j]+=1
ct=0
for i in range(len(L)):
  if L[i]==1:ct+=1
print(ct)
for i in range(len(L)):
  if L[i]==1:print(i)

Submission status: Wrong Answer

Solution code:
import io
import sys


def IN_S():
  return input()


def IN_I():
  return int(input())


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


def IN_L_S():
  return list(map(str, input().split()))


def STR_SPLIT(s, n):
  for l in range(0, len(s), n):
    yield s[0 + l:n + l]


def T_IN():
  global test_str
  sys.stdin = io.StringIO(test_str[1:-1])


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


test_str = '''
3
1 0 0
'''


def MAIN():
  # T_IN()
  A()


def A():
  n = IN_I()
  li = IN_L_I()

  tmp = [False] * n

  for i, b in enumerate(reversed(li)):
    ci = n - i - 1
    # print("hoge:",i,b,ci)
    if b == 1 and not tmp[ci]:
      tmp[ci] = True

    if b == 1:
      for j in make_divisors(ci + 1):
        if j != ci + 1:
          tmp[j] = not tmp[j]

    # print(tmp)

  puts = [i * 1 for i, x in enumerate(tmp) if x]
  print(len(puts))
  if len(puts) > 0:
    print(" ".join([str(i + 1) for i in puts]))
  return None


def B():
  return None


def C():
  return None


MAIN()

Submission status: Wrong Answer

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

for i in range(mid,0,-1):
    s = N // i + 1
    t = 0
    for j in range(1,s):
        t += l[i*j-1]
    if t%2==0:
        if l[i]%2==1:
            ans_l.append(str(i))
            l[i-1] += 1
    else:
        if l[i]%2==0:
            ans_l.append(str(i))
            l[i-1] += 1

leng = len(ans_l)
print(leng)
if leng==0:
    print(0)
else:
    print(" ".join(ans_l))

Submission status: Wrong Answer

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

for i in reversed(range(n)):
  if n/2 < i :
    tmp = 2
    sum_num = 0
    while (tmp*(i+1) - 1) <= n:
      sum_num += 1 if b[tmp*(i+1)-1] == 1 else 0
      tmp += 1
      
    b[i] = 0 if sum_num %2 == 0 else 1
  else:
    b[i] = a[i]
  
  if b[i] == 1:
    count += 1
    ans.append(str(i+1))
    
list.sort(ans)
print(count)
print(' '.join(ans))

Submission status: Wrong Answer

Solution code:
from math import ceil
n = int(input())
a = list(map(int, input().split()))

box = [0]*n
for i in range(2, n):
    for j in range(n//(i-1), n//i, -1):
        box[j-1] = a[j-1]
        for k in range(1, i):
            box[j-1] -= a[j*k-1]
        if box[j-1]<0:
            print(-1)
            exit()
box[0] = sum(a)

print(box[0])
for i, m in enumerate(box):
    if m: print(i+1)

Submission status: Wrong Answer

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

for i in range(N, 0, -1):
  tmp = 0
  for x in range(2, N):
    j = i * x
    if j > N:
      break
    tmp += B[j - 1]

  mod = tmp % 2
  if A[i - 1] == 0:
    if mod == 0:
      pass
    else:
      B[i - 1] = 1
      M.append(i)
  else:
    if mod == 0:
      B[i - 1] = 1
      M.append(i)
    else:
      pass

print(len(M))
if len(M) > 0:
  print(' '.join(map(str, reversed(M))))

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

Submission status: Wrong Answer

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

ans = [0 for _ in range(N // 2 + 1)] + A[N // 2:]

for i in range(N // 2, 1, -1):
    count = 0
    n = i
    j = 2
    while n * j < N:
        count += ans[n * j]
        j += 1
    ans[i] = (count + A[i - 1]) % 2

sans = sum(ans)

ans[1] = (sans + A[0]) % 2

sans += ans[1]

print(sans)
p = ''
for i in range(1, N + 1):
    if ans[i] == 1:
        p += str(i) + ' '

print(p)

Submission status: Wrong Answer

Solution code:
from bisect import bisect_left


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]]


n = int(input())
a = list(map(int, input().split()))
prime = primes(n)
ans = [0] * n


def dfs(d, n):
    global prime
    global ans
    res = 0
    for i in range(bisect_left(prime, d), len(prime)):
        if d * prime[i] > n:
            break
        res += dfs(d * prime[i], n)
    if (res + a[d - 1]) % 2 == 1:
        ans[d - 1] = 1
        res += 1
    return res


dfs(1, n)
c = ans.count(1)
print(c)
if c != 0:
    print(' '.join([str(i + 1) for i, x in enumerate(ans) if x == 1]))

Submission status: Wrong Answer

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

ans=[]
div=N//2
j=1
for i in reversed(range(N)):
    if i+1 < div:
        j+=1
        div=div//2
    at=0
    for jt in range(j):
        at+=A[(i+1)*(jt+1)-1]
    if at==1:ans.append(i+1)

ans.reverse()
print(len(ans))
for i in ans:print(str(i)+' ',end="")

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [int(i) for i in input().split()]
l = [0] * n

cnt = 0
for i in range(1, n + 1)[::-1]:
    s = sum([l[(j + 2) * i - 1] for j in range(n // i - 1)])
    l[i - 1] = (s + a[i - 1]) % 2
    cnt += l[i - 1]

print(cnt)
for i, k in enumerate(l):
    if k != 0:
        print(k, end=" ")

Submission status: Wrong Answer

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

N_ = N
half_N = (N // 2)
ans = []
while N_ > half_N:
	if a[N_ - 1] == 1:
		ans.append(N_)
	N_ -= 1
ans = np.array(ans)
while N_ > 0:
	if (np.count_nonzero(ans % N_ == 0) % 2) != a[N_ - 1]:
		ans = np.append(ans,N_)
	N_ -= 1

print(len(ans))
for i in ans:
	print(i,end = " ")

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int, input().split()))
b = []
Flag = True
for i in reversed(range(1, N+1)):
    j = 2
    count = 0
    while True:
        if i*j <= N:
            count += a[i*j-1]
            j += 1
        else:
            break
    if count+1 == a[i-1]:
        b.append(a[i-1])
    elif count == a[i-1]:
        continue
    else:
        Flag = False
        break
if Flag:
    b.reverse()
    ans = sum(b)
    print(ans)
    if ans != 0:
        print(*b)
else:
    print("-1")

Submission status: Wrong Answer

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

n = int(input())
a = list(map(int, input().split()))
ans = [0]*n
cnt = 0
for i in range(1, n+1):
    dp = cnt%2
    if a[n-i] == 0 and dp == 0:
        ans[i-1] = 0
    elif a[n-i] == 1 and dp == 1:
        ans[i-1] = 0
    elif a[n-1] == 1 and dp == 0:
        ans[i-1] = 1
        cnt += 1
    elif a[n-i] == 0 and dp == 1:
        ans[i-1] = 1
        cnt += 1
print(cnt)
if cnt == 0:
    sys.exit()
for i in range(n):
    if ans[n-i-1] == 1:
        print(i+1, end=" ")

Submission status: Wrong Answer

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

nums = []
memo = [0] * N
for i in range(N - 1, -1, -1):
    if sum(A[i : :i + 1]) % 2 != sum(memo[i :: i + 1]) % 2:
        memo[i] = 1
        nums.append(A[i])
        
print(sum(memo))
print(' '.join(map(str, nums)))

Submission status: Wrong Answer

Solution code:
def solve():
    n = int(input())
    A = [0] + list(map(int, input().split()))
    for i in range(n // 2, 1, -1):
        t = len([1 for k in range(i, n + 1, i) if A[k] == 1]) & 1
        if A[i] != t:
            A[i] = 1 - A[i]
    if A[1] != (sum(A) & 1):
        A[1] = 1 - A[0]
    print(sum(A))
    print(*list(A[i] for i in range(1, n + 1) if A[i]))
solve()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python

import sys
from math import ceil

n= int(sys.stdin.readline())
a= [ int(x) for x in sys.stdin.readline().split() ]
check= [ [] for _ in range(n) ]
ans= [-1]*n
c = ceil(n/2)
for i in range(c,n+1):
    j= i-1
    ans[j]= a[j]
#
for i in range(c-2,-1,-1):
    j= i+1
    s= a[i]
    for k in range(2*j,n+1,j): s+= ans[k-1]
    ans[i]= s%2
#
m= sum(ans)
print( m )
if m>0:
    for i in range(n):
        if ans[i]: print( i+1,end=" " )

Submission status: Wrong Answer

Solution code:
N = int(input())

a = list(map(int, input().split()))
b = [0] * N
flag = True
for k in range(N):
    i = N - k
    count = 0
    for m in range(i, N, i):
        count += b[m]
    t = count % 2
    absv = a[i - 1] - count
    if absv == 0:
        pass
    elif absv == 1:
        b[i - 1] = 1
    else:
        print(-1)
        flag = False
        break

if flag:
    print(sum(b))
    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()))
x = [-1]*N
b = []
for i in range(N,0,-1):
    m = N//i
    x[i-1] = int(sum(x[j] for j in range(i*2-1,i*m,i)) != a[i-1])
    if x[i-1] == 1:
        b.append(i)
print(len(b))
if len(b) > 0:
    print(" ".join(map(str, b)))

Submission status: Wrong Answer

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

sum=0
count=0
OK_Flag=True
OK_list=[]

for i in range(1,N+1):
  sum=0
  if OK_Flag==True:  
    for j in range(i,N+1,i):    
        #print(i,A[j-1])
        sum=sum+A[j]
    if sum%2==A[i]:
      if A[i]==1:
        count=count+1
        OK_list.append(A[i])
    else:
      OK_Flag=False

if OK_Flag==True:
  print(count)
  if count!=0:
    print(' '.join(map(str, OK_list)))
else:
  print(-1)

Submission status: Wrong Answer

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

print(0)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
B=[0]*n
for i in range(n,0,-1):
    if n//i>1:
        l=n//i
        cnt=0
        for k in range(2,l+1):
            cnt+=B[i*k-1]
        if cnt%2!=a[i-1]:
            B[i-1]=1
    else:
        if a[i-1]==1:
            B.append(i)
k=B.count(1)
print(k)
ans=[]
for i in range(n):
    if B[i]==1:
        ans.append(str(i+1))
print(' '.join(ans))

Submission status: Wrong Answer

Solution code:
def calc_sum(orig_index, index_list):
    _sum = 0
    index = orig_index*2
    while index <= N:
        if index in index_list:
            _sum += 1
        index += orig_index
    return _sum

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

boxes = []
ans = ""
for i,a in enumerate(A[::-1]):
    index = N - i
    if index <= N//2:
        if a != calc_sum(index, boxes) % 2:
            boxes.append(index)
            ans += (str(index) + " ")
    elif a == 1:
        boxes.append(index)
        ans += (str(index) + " ")

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



# for i,a in enumerate(A):

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
b=[0]*(n+1)
for i in reversed(range(1,n+1)):
    tmp_num=i
    tmp=0
    while tmp_num<=n:
        tmp+=a[tmp_num-1]
        tmp_num+=i
    b[i]=tmp%2
cnt=0
c=[]
for i in range(len(b)):
    if b[i]==1:
        cnt+=1
        c.append(str(i))
print(cnt)
if cnt!=0:
    print(" ".join(c))

Submission status: Wrong Answer

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

for i in range(N, 0, -1):
  tmp = 0
  for x in range(2, N):
    j = i * x
    if j > N:
      break
    tmp += B[j - 1]

  mod = tmp % 2
  if A[i - 1] == 0:
    if mod == 0:
      pass
    else:
      B[i - 1] = 1
      M.append(str(i))
  else:
    if mod == 0:
      B[i - 1] = 1
      M.append(str(i))
    else:
      pass

print(len(M))
if len(M) > 0:
  print(' '.join(reversed(M)))