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:
import sys

input = lambda: sys.stdin.readline().rstrip()


def solve():

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

    oe = [0] + [-1 for i in range(N)]

    for i in range(N, 0, -1):
        num = i
        j = 1
        flag = True if A[i] == 0 else False
        while num <= N:
            if oe[num] == -1:
                oe[num] = flag
            else:
                f = True if oe[num] == 0 else False
                flag = not(flag ^ f)
            j += 1
            num = i * j

    oe.pop(0)
    oe = [0 if f else 1 for f in oe]
    print(N)
    print(' '.join(map(str, oe)))


if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

Solution code:
def divisor(n):
    # nの約数列挙
    ass = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            ass.append(i)
            if i**2 == n:
                continue
            ass.append(n//i)
    return ass  # sortされていない


N = int(input())
*a, = map(int, input().split())
a = [0]+a
b = []
c = [0]*(N+1)
divs = sorted(divisor(N))

for i in range(N, 0, -1):
    if c[i] % 2 != a[i]:
        b.append(i)
        for d in divs:
            if d > i:
                break
            if i % d == 0:
                c[d] += 1

print(len(b))
if len(b) > 0:
    print(*b)

Submission status: Wrong Answer

Solution code:
def divisor(n):
    # nの約数列挙
    ass = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            ass.append(i)
            if i**2 == n:
                continue
            ass.append(n//i)
    return ass  # sortされていない


N = int(input())
*a, = map(int, input().split())
a = [0]+a
b = []
c = [0]*(N+1)
divs = sorted(divisor(N))

for i in range(N, 0, -1):
    if c[i] % 2 != a[i]:
        b.append(i)
        for d in divs:
            if d > i:
                break
            c[d] += 1

print(len(b))
if len(b) > 0:
    print(*b)

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):
    sum = 0
    for j in range(i + i, n, i + 1):
        sum += ans[j]

    ans[i] = a[i] - sum
    ans[i] %= 2

print(ans.count(1))

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

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):
    sum = 0
    for j in range(i + i, n, i + 1):
        sum += ans[j]

    ans[i] = a[i] - sum
    ans[i] %= 2

print(ans.count(1))

ans_array = []
for i in range(n):
    if ans[i] == 1:
        ans_array.append(str(i + 1))

print(" ".join(ans_array))

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):
    sum = 0
    for j in range(i + i, n, i + 1):
        sum += ans[j]

    ans[i] = a[i] - sum
    ans[i] %= 2

print(ans.count(1))

for i in range(n):
    if ans[i] == 1:
        print(i + 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):
    sum = 0
    for j in range(i + i, n, i + 1):
        sum += ans[j]

    ans[i] = a[i] - sum
    ans[i] %= 2

print(ans.count(1))

for i in range(n):
    if ans[i] == 1:
        print(i + 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):
    sum = 0
    for j in range(i + i, n, i + 1):
        sum += ans[j]

    ans[i] = a[i] - sum
    ans[i] %= 2

print(ans.count(1))

for i in range(n):
    if ans[i] == 1:
        print(ans[i], 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):
    xor = a[i]
    for j in range(i + i, n, i + 1):
        xor ^= ans[j]

    ans[i] ^= xor

print(ans.count(1))

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

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
b = []
for i in reversed(range(n)):
    if a[i]:
        num = i + 1
        b.append(num)
        tmp = 1
        while tmp * tmp <= num:
            if num % tmp == 0:
                a[num-1] ^= 1
                if tmp != num // tmp:
                    a[num//tmp-1] ^= 1
            tmp += 1
print(len(b))
print(*b)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int ,input().split()))
import math
def is_prime(n):
	if n == 1:
		return False
	
	for k in range(2, int(math.sqrt(n)) + 1):
		if n%k == 0:
			return False
	return True

cnt = 0
b = []
for i in range(n):
  if a[i] == 1:
    if i == 0:
      cnt += 1
      b.append(i+1)
      continue
    if is_prime(a[i]):
      cnt +=1
      b.append(i+1)
    else:
      print (-1)
      exit()
print (cnt)
if len(b) != 0:
  print (*b)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int ,input().split()))
import math
def is_prime(n):
	if n == 1:
		return False
	
	for k in range(2, int(math.sqrt(n)) + 1):
		if n%k == 0:
			return False
	return True

cnt = 0
b = []
for i in range(n):
  if a[i] == 1:
    if i == 0:
      cnt += 1
      b.append(i+1)
      continue
    if is_prime(a[i]):
      cnt +=1
      b.append(i+1)
    else:
      print (-1)
      exit()
print (cnt)
print (*b)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int ,input().split()))
import math
def is_prime(n):
	if n == 1:
		return False
	
	for k in range(2, int(math.sqrt(n)) + 1):
		if n%k == 0:
			return False
	return True

cnt = 0
b = []
for i in range(n):
  if a[i] == 1:
    if i == 0:
      cnt += 1
      b.append(i+1)
      continue
    if is_prime(a[i]):
      cnt +=1
      b.append(i+1)
print (cnt)
print (*b)

Submission status: Wrong Answer

Solution code:
# region header
import sys
import math
from bisect import bisect_left, bisect_right, insort_left, insort_right
from collections import defaultdict, deque, Counter
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from heapq import heappop, heappush
from itertools import accumulate, groupby, product, permutations, combinations, combinations_with_replacement
from math import ceil, floor, factorial, log, sqrt, sin, cos
from operator import itemgetter
from string import ascii_lowercase, ascii_uppercase, digits
sys.setrecursionlimit(10**6)
INF = float('inf')
MOD = 10 ** 9 + 7
def rs(): return sys.stdin.readline().rstrip()
def ri(): return int(rs())
def rf(): return float(rs())
def rs_(): return [_ for _ in rs().split()]
def ri_(): return [int(_) for _ in rs().split()]
def rf_(): return [float(_) for _ in rs().split()]
def divisors(n, sortedresult=True):
    div = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            div.append(i)
            if i != n // i:
                div.append(n//i)
    if sortedresult:
        div.sort()
    return div
# endregion
N = ri()
a = ri_()
b = [0] * N
for i in reversed(range(N)):
    if (a[i] + sum(b[i + 1:])) % 2 == 1:
        b[i] = 1
print(sum(b))
for i in range(N):
    if b[i] == 1:
        print(i + 1, end = ' ')
print('\n', end = '')

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, 0, -1):
    # mod2 の足し算は xor
    sum_a = 0
    for j in range(i + i, N + 1, i):
        sum_a ^= A[j]
    B[i] = sum_a ^ A[i]

# print(A, B)
out = []
for i in range(1, N + 1):
    if B[i] == 1:
        out.append(i)
if len(out) > 0:
    print(len(out))
    print(*out)
else:
    print(0)

Submission status: Wrong Answer

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

B = [0] * (N + 1)


def factorization(n):
    """
    素因数分解
    factorization(24)
    [[2, 3], [3, 1]]
    24 = 2^3 * 3^1
    """
    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, cnt])

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

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

    return arr


for i in range(1, N + 1):
    if A[i] == 1:
        B[i] = 1
        fact_i = factorization(i)
        # print(i, fact_i)
        if i == 1:
            continue
        for j in range(len(fact_i)):
            B[fact_i[j][0]] = (B[fact_i[j][0]] + 1) % 2

# print(A, B)
out = []
for i in range(1, N + 1):
    if B[i] == 1:
        out.append(i)
if len(out) > 0:
    print(len(out))
    print(*out)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
import collections
import heapq
n = int(raw_input())
ais = [0] + map(int, raw_input().split()) 
res = [0 for __ in range(n +1)]
for u in range(n, 0, -1):
	c = u*2
	cumul = 0
	for jj in range(u, n+1, u):
		cumul += res[jj]
	
	if ais[u] != (cumul % 2): 
		res[u] = 1
s = sum(res)
print s
if s:
	print ''.join([str(i) for i in range(len(res)) if res[i] == 1])

Submission status: Wrong Answer

Solution code:
import collections
import heapq
n = int(raw_input())
ais = [0] + map(int, raw_input().split()) 
#print ais
res = [0 for __ in range(n +1)]
for u in range(n, 0, -1):
	c = u*2
	cumul = 0
	while(c <= n):
		cumul += res[c]
		c += u
	if ais[u] != (cumul % 2): 
		res[u] = 1
s = sum(res)
print s
if s:
	print ''.join([str(i) for i in range(len(res)) if res[i] == 1])

Submission status: Wrong Answer

Solution code:
import collections
import heapq
n = int(raw_input())
ais = [0] + map(int, raw_input().split(' ')) 
res = [0 for __ in range(n +1)]
for u in range(n, 0, -1):
	c = u*2
	cumul = 0
	while(c <= n):
		cumul += res[c]
		c += u
	if ais[u] != (cumul % 2): 
		res[u] = 1
s = sum(res)
print s
if s:
	print ''.join([str(i) for i in range(len(res)) if res[i] == 1])

Submission status: Wrong Answer

Solution code:
import collections
import heapq
n = int(raw_input())
ais = [0] + map(int, raw_input().split(' ')) 
res = [0] * (n +1)
for u in range(n, 0, -1):
	c = u*2
	cumul = 0
	while(c <= n):
		cumul += res[c]
		c += u
	if ais[u] != (cumul % 2): 
		res[u] = 1
s = sum(res)
print s
if s:
	print ''.join([str(i) for i in range(len(res)) if res[i] == 1])

Submission status: Wrong Answer

Solution code:
import collections
import heapq
n = int(raw_input())
ais = [0] + map(int, raw_input().split(' ')) 
res = [0] * (n +1)
for u in range(n, 0, -1):
	c = u *2
	cumul = 0
	while(c <= n):
		cumul += res[c]
		c += u


	if ais[u] == 1:
		if cumul % 2 == 0: res[u] = 1
	elif ais[u] == 0:
		if cumul % 2 == 1: res[u] = 1
cc = collections.Counter(res)
print cc[1]
print ''.join([str(i) for i in range(len(res)) if res[i]])

Submission status: Wrong Answer

Solution code:
import collections
import heapq
n = int(raw_input())
ais = [0] + map(int, raw_input().split(' ')) 
res = [0] * (n +1)
for u in range(n, 0, -1):
	c = u *2
	cumul = 0
	while(c <= n):
		cumul += res[c]
		c += u


	if ais[u] != cumul % 2: res[u] = 1
cc = collections.Counter(res)
print cc[1]
print ''.join([str(i) for i in range(len(res)) if res[i]])

Submission status: Wrong Answer

Solution code:
import collections
import heapq
n = int(raw_input())
ais = [0] + map(int, raw_input().split(' ')) 
res = [0] * (n +1)
for u in range(n, 0, -1):
	c = u *2
	cumul = 0
	while(c <= n):
		cumul += res[c]
		c += u


	if ais[u] == 1:
		if cumul % 2 == 0: res[u] = 1
	elif ais[u] == 0:
		if cumul % 2 == 1: res[u] = 1
cc = collections.Counter(res)
print cc[1]
if cc[1]:
	print ''.join([str(i) for i in range(len(res)) if res[i]])

Submission status: Wrong Answer

Solution code:
import collections
import heapq
n = int(raw_input())
ais = [0] + map(int, raw_input().split(' ')) 
res = [0] * (n +1)
for u in range(n, 0, -1):
	c = u *2
	cumul = 0



	if ais[u] == 1:
		if cumul % 2 == 0: res[u] = 1
	elif ais[u] == 0:
		if cumul % 2 == 1: res[u] = 1
cc = collections.Counter(res)
print cc[1]
if cc[1]:
	print ''.join([str(i) for i in range(len(res)) if res[i]])

Submission status: Wrong Answer

Solution code:
import collections
import heapq
n = int(raw_input())
ais = map(int, raw_input().split(' ')) 
res = [None] * (n +1)
for j in range(len(ais)-1, -1, -1):
	u = j + 1
	c = u *2
	cumul = 0
	while(c <= n):
		cumul += res[c]
		c += u

	if ais[u - 1] == 1:
		if cumul % 2 == 0:
			res[u] = 1
		else:
			res[u] = 0
	elif ais[u - 1] == 0:
		if cumul % 2 == 0:
			res[u] = 0
		else:
			res[u] = 1
cc = collections.Counter(res)
print cc[1]
if cc[1]:
	print ''.join([str(i) for i in range(len(res)) if res[i]])

Submission status: Wrong Answer

Solution code:
import collections
import heapq
n = int(raw_input())
ais = map(int, raw_input().split(' ')) 
res = [None] * (n +1)
for j in range(len(ais)-1, -1, -1):
	u = j + 1
	c = u  * 2
	co = 0
	while(c < n):
		co += 1 if res[c]%2 else 0
		c += u
	if ais[u - 1] == 1:
		if co % 2 == 0:
			res[u] = 1
		else:
			res[u] = 0
	elif ais[u - 1] == 0:
		if co % 2 == 0:
			res[u] = 0
		else:
			res[u] = 1
cc = collections.Counter(res)
print cc[1]
if cc[1]:
	print ''.join([str(i) for i in range(len(res)) if res[i]])

Submission status: Wrong Answer

Solution code:
import collections
import heapq
n = int(raw_input())
ais = map(int, raw_input().split(' ')) 
res = [None] * (n +1)
for j in range(len(ais)-1, -1, -1):
	u = j + 1
	c = u  * 2
	co = 0
	while(c < n):
		co += 1 if res[c]%2 else 0
		c += u
	if ais[u - 1] == 1:
		if co % 2 == 0:
			res[u] = 1
		else:
			res[u] = 0
	elif ais[u - 1] == 0:
		if co % 2 == 0:
			res[u] = 0
		else:
			res[u] = 1
cc = collections.Counter(res)
print cc[1]
print ''.join([str(i) for i in range(len(res)) if res[i]])

Submission status: Wrong Answer

Solution code:
n = int(input())
aa = tuple(map(int, input().split()))

balls = set()
for i in range(n, 0, -1):
    r = aa[i - 1]
    
    x = 0
    for j in range(i, n, i):
        if j in balls:
            x += 1
    if x % 2 != r:
        balls.add(i)
print(len(balls))
if balls:
    print(' '.join(map(str, balls)))

Submission status: Wrong Answer

Solution code:
from sys import stdin, setrecursionlimit


def main():
    input = stdin.buffer.readline
    n = int(input())
    a = list(map(int, input().split()))
    b = [0] * n
    for i in range(n):
        mod = n - i
        x = 0
        tmp = 0
        while x * mod <= n:
            tmp += b[x * mod - 1]
            x += 1
        if tmp % 2 != a[mod - 1]:
            b[mod - 1] = 1

    ans_m = 0
    ans_b = []
    for i in range(n):
        if b[i] > 0:
            ans_m += 1
            ans_b.append(i + 1)
    print(ans_m)
    if len(ans_b) > 0:
        print(*ans_b)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()

Submission status: Wrong Answer

Solution code:
#coding: utf-8
N = int(input())
A = [0] + list(map(int, input().split()))
B = [0 for _ in range(N+1)]
ans = []
for i in range(N, 0, -1):
    v = -A[i]
    j = i
    while j <= N:
        # print("i,j", i, j)
        v += A[j]
        j += i+1
    if A[i] != v % 2:
        ans.append(i)
        B[i] = 1

ans.sort()
print(len(ans))
if len(ans) != 0:
    print(*ans)

Submission status: Wrong Answer

Solution code:
#coding: utf-8
N = int(input())
A = list(map(int, input().split()))
B = []
for i in range(N-1, -1, -1):
    v = 0
    j = 2*i+1
    while j < N:
        # print("i,j", i, j)
        if A[j] == 1:
            v += 1
        j += i+1
    if A[i] == 1 and v % 2 == 0:
        B.append(i+1)
        A[i] = 1
    elif A[i] == 0 and v % 2 == 1:
        B.append(i+1)
        A[i] = 1
B.sort()
print(len(B))
if len(B) != 0:
    print(*B)

Submission status: Wrong Answer

Solution code:
#coding: utf-8
N = int(input())
A = list(map(int, input().split()))
B = []
for i in range(N-1, -1, -1):
    v = 0
    for j in range(2*i+1, N, i+1):
        # print("i,j", i, j)
        if A[i] == 1:
            v += 1
    if A[i] == 1 and v % 2 == 0:
        B.append(i+1)
        A[i] = 1
    elif A[i] == 0 and v % 2 == 1:
        B.append(i+1)
        A[i] = 1
B.sort()
print(len(B))
if len(B) != 0:
    print(*B)

Submission status: Wrong Answer

Solution code:
#coding: utf-8
N = int(input())
A = list(map(int, input().split()))
B = []
for i in range(N-1, -1, -1):
    v = 0
    for j in range(2*i, N, i+1):
        # print("i,j", i, j)
        if A[i] == 1:
            v += 1
    if A[i] == 1 and v % 2 == 0:
        B.append(i+1)
        A[i] = 1
    elif A[i] == 0 and v % 2 == 1:
        B.append(i+1)
        A[i] = 1
B.sort()
print(len(B))
if len(B) != 0:
    print(*B)

Submission status: Wrong Answer

Solution code:
#coding: utf-8
N = int(input())
A = list(map(int, input().split()))
B = []
for i in range(N-1, -1, -1):
    v = 0
    for j in range(2*i, N, i+1):
        print("i,j", i, j)
        if A[i] == 1:
            v += 1
    if A[i] == 1 and v % 2 == 0:
        B.append(i+1)
        A[i] = 1
    elif A[i] == 0 and v % 2 == 1:
        B.append(i+1)
        A[i] = 1
B.sort()
print(len(B))
if len(B) != 0:
    print(*B)

Submission status: Wrong Answer

Solution code:
from collections import deque

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

sep = n//2
tmp = 0
ans = 0
li2 = []

deq = deque(li[sep:])

for i in range(sep-1,-1,-1):
    cnt = sep//n
    for j in range(cnt):
        tmp += li[cnt*j-1]
    tmp%=2
    if li[i]==0:
        deq.appendleft(tmp)
    else:
        deq.appendleft(tmp^1)

li1 = list(deq)

for i,v in enumerate(li1):
    if v==1:
        ans+=1
        li2.append(i+1)

if ans==0:
    print(ans)
else:
    print(ans)
    print(*li2)

Submission status: Wrong Answer

Solution code:
#coding: utf-8
N = int(input())
A = list(map(int, input().split()))
B = []
for i in range(N-1, -1, -1):
    v = 0
    for j in range(2*i-1, N, i+1):
        if A[i] == 1:
            v += 1
    if A[i] == 1 and v % 2 == 0:
        B.append(i+1)
    elif A[i] == 0 and v % 2 == 1:
        B.append(i+1)
B.sort()
print(len(B))
if len(B) != 0:
    print(*B)

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    A = list(map(int, input().split()))
    A.insert(0, 1e10)
    ans = []
    for i in range(1, len(A)):
        idx = i
        s = 0
        while idx <= len(A) - 1:
            s += A[idx]
            idx += i

        if s % 2 != 0:
            ans.append(i)
    
    if len(ans) > 0:
        print(len(ans))
        print(*ans)
    else:
        print(0)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    A = list(map(int, input().split()))
    A.insert(0, 1e10)
    ans = []
    for i in range(len(A) - 1, 0, -1):
        idx = i
        s = 0
        while idx <= len(A) - 1:
            s += A[idx]
            idx += i

        if s % 2 != 0:
            ans.append(i)
    
    if len(ans) > 0:
        print(*ans)
    else:
        print(0)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#coding: utf-8
N = int(input())
A = list(map(int, input().split()))
B = []
for i in range(N-1, -1, -1):
    v = 0
    for j in range(2*i-1, N, i+1):
        if A[i] == 1:
            v += 1
    if A[i] == 1 and v % 2 == 0:
        B.append(i+1)
B.sort()
print(len(B))
if len(B) != 0:
    print(*B)

Submission status: Wrong Answer

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

for i in range(n, 0, -1):
    if a[i - 1] == 1:
        if sum(arr[i::i]) % 2 == 0:
            arr[i - 1] = True
    else:
        if sum(arr[i::i]) % 2 == 1:
            arr[i - 1] = False

if not any(arr):
    print(0)
else:
    print(sum(arr))
    ans = []
    for i, x in enumerate(arr):
        if x:
            ans.append(i + 1)
    print(*ans)

Submission status: Wrong Answer

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

for i in range(n, 0, -1):
    if a[i - 1] == 1:
        if sum(arr[0::i]) % 2 == 0:
            arr[i - 1] = True
    else:
        if sum(arr[0::i]) % 2 == 1:
            arr[i - 1] = False

if not any(arr):
    print(0)
else:
    print(sum(arr))
    ans = []
    for i, x in enumerate(arr):
        if x:
            ans.append(i + 1)
    print(*ans)

Submission status: Wrong Answer

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

for i in range(n, 0, -1):
    if a[i - 1] == 1:
        if sum(arr[0::i]) % 2 == 0:
            arr[i - 1] = True
    else:
        if sum(arr[0::i]) % 2 == 1:
            arr[i - 1] = False

arr = [int(x) for x in arr]

for i, a in enumerate(arr[::-1]):
    if a == 1:
        break

arr = arr[:-i]

if 1 not in arr:
    print(0)
else:
    print(sum(arr))
    ans = []
    for i, x in enumerate(arr):
        if x == 1:
            ans.append(i + 1)
    print(*ans)

Submission status: Wrong Answer

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

for i in range(n, 0, -1):
    if a[i - 1] == 1:
        if sum(arr[0::i]) % 2 == 0:
            arr[i - 1] = True
    else:
        if sum(arr[0::i]) % 2 == 1:
            arr[i - 1] = False

arr = [int(x) for x in arr]

for i, a in enumerate(arr[::-1]):
    if a == 1:
        break

arr = arr[:-i]

if 1 not in arr:
    print(0)
else:
    print(len(arr))
    print(*arr)

Submission status: Wrong Answer

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

ans = [0] * n

for i in reversed(range(1, n+1)):
    count = 0
    for j in range(i+1, n+1, i):
        count += ans[j-1]

    if count % 2 != a[i-1]:
        ans[i-1] = 1

print(sum(ans))
for i in range(n):
    if ans[i] == 1:
        print(i + 1)

Submission status: Wrong Answer

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

ans = [0] * n

for i in reversed(range(1, n+1)):
    count = 0
    for j in range(i+1, n+1, i):
        count += ans[j-1]

    if count % 2 != a[i-1]:
        ans[i-1] = 1

for _ans in ans:
    print(_ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
A = list(map(int,input().split()))
mod = [0]*(n+1)
ans = []
for i in range(n,0,-1):
    if (A[i-1] == 1 and mod[i]%2 == 0) or (A[i-1] == 0 and mod[i]%2 == 1):
        ans.append(i)
        for j in range(1,int(i**(0.5))):
            if A[i-1]%j==0:
                mod[j] += 1
                mod[A[i-1]//j] += 1
        if A[i-1] % int(i**(0.5)) == 0:
            mod[int(i**(0.5))] += 1
print(len(ans))
print(" ".join(map(str,ans)))

Submission status: Wrong Answer

Solution code:
def divs(n):
    res = []
    i = 1
    while i**2 <= n:
        if n%i == 0: 
            res.append(i)
            if i**2 != n:
                res.append(n//i)
        i+=1 
    return res


def main():
    n = int(input())
    al_0 = list(map(int, input().split()))
    if sum(al_0) == 0:
        print(0)
        return

    al = [0] + al_0
    divs_cnts = [0]*(n+1)
    ans = []
    for i in range(n,0,-1):
        if divs_cnts[i]%2 != al[i]%2:
            ans.append(i)
            div_l = divs(n)
            for d in div_l:
                divs_cnts[d] += 1

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


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def divs(n):
    res = []
    i = 1
    while i**2 <= n:
        if n%i == 0: res.append(i)
        i+=1 
    return res


def main():
    n = int(input())
    al_0 = list(map(int, input().split()))
    if sum(al_0) == 0:
        print(0)
        return

    al = [0] + al_0
    divs_cnts = [0]*(n+1)
    ans = []
    for i in range(n,0,-1):
        if divs_cnts[i]%2 != al[i]%2:
            ans.append(i)
            div_l = divs(n)
            for d in div_l:
                divs_cnts[d] += 1

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


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def divs(n):
    res = []
    i = 1
    while i**2 <= n:
        if n%i == 0: res.append(i)
        i+=1 
    return res


def main():
    n = int(input())
    al_0 = list(map(int, input().split()))
    if sum(al_0) == 0:
        print(-1)
        return
    al = [0] + al_0
    divs_cnts = [0]*(n+1)
    ans = []
    for i in range(n,0,-1):
        if divs_cnts[i]%2 != al[i]%2:
            ans.append(i)
            div_l = divs(n)
            for d in div_l:
                divs_cnts[d] += 1

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


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def divs(n):
    res = []
    i = 1
    while i**2 <= n:
        if n%i == 0: res.append(i)
        i+=1 
    return res


n = int(input())
al_0 = list(map(int, input().split()))
al = [0] + al_0
divs_cnts = [0]*(n+1)
ans = []
for i in range(n,0,-1):
    if divs_cnts[i]%2 != al[i]:
        ans.append(i)
        div_l = divs(n)
        for d in div_l:
            divs_cnts[d] += 1

if ans:
    print(len(ans))
    print(*ans)
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
n=int(input())

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

nice_box = [-1]*n

for i in range(n-1,-1,-1):
  baisu = 2
  ball_memo = 0
  index = i+1
  while baisu * index - 1 < n:
    ball_memo += nice_box[baisu * index - 1]
    baisu += 1

  if ball_memo % 2 == a[i]:
    nice_box[i] = a[i]
  else:
    nice_box[i] = (ball_memo+1)%2

ans = []

for i in range(n):
  if nice_box[i] == 1:
    ans.append(i+1)

print(len(ans))
if len(ans)>0:
  print(*ans)

Submission status: Wrong Answer

Solution code:
n=int(input())

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

nice_box = [-1]*n

for i in range(n-1,-1,-1):
  baisu = 1
  ball_memo = 0
  index = i+1
  while baisu * index - 1 < n:
    if nice_box[baisu * index - 1] != -1:
      ball_memo += nice_box[baisu * index - 1]
    baisu += 1

  if ball_memo % 2 == a[i]:
    nice_box[i] = a[i]
  else:
    nice_box[i] = (ball_memo+1)%2

ans = []

for i in range(n):
  if nice_box[i] == 1:
    ans.append(i+1)

print(len(ans))
if len(ans)>0:
  print(*ans)

Submission status: Wrong Answer

Solution code:
n=int(input())

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

nice_box = [-1]*n

for i in range(n-1,-1,-1):
  baisu = 1
  ball_memo = 0
  index = i+1
  while baisu * index < n:
    if nice_box[baisu * index - 1] != -1:
      ball_memo += nice_box[baisu * index - 1]
    baisu += 1

  if ball_memo % 2 == a[i]:
    nice_box[i] = a[i]
  else:
    nice_box[i] = (ball_memo+1)%2

ans = []

for i in range(n):
  if nice_box[i] == 1:
    ans.append(i+1)

print(len(ans))
if len(ans)>0:
  print(*ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
ans = [0] * n
m = 0
res = []
# 1 idx
for i in range(n, 0, -1):
    if a[i - 1]:
        # i の倍数でbit立っているものの個数を数える
        cnt = 0
        idx = 2
        while i * idx < n:
            if ans[i * idx - 1]:
                cnt += 1
            idx += 1
        if cnt % 2 == 0:
            ans[i - 1] = 1
            m += 1
            res.append(i)
print(m)
if m:
    print(*res)

Submission status: Wrong Answer

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

ball = [0]*n

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

    a[i-1] ^= sum(ball[i-1:n:i]) % 2
    
    if a[i-1] == 1:
        ball[i-1] =1

print(a)


if sum(ball) > 0:
    print(sum(ball))
    print(*[i+1 for i in range(n) if ball[i] > 0]) 

else:
    print(0)

Submission status: Wrong Answer

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

count = 0
for i in reversed(range(1, n+1)):
    for j in range(2*i-1, n, i): 
        a[i-1] ^= a[j]

    if a[i-1] == 1:
            count += 1
        
if count:
    print(count)
    print(a)

else:
    print(0)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [0]+list(map(int,input().split()))
x = [0]*(n+1)
for i in range(n,0,-1):
    buf = 0
    for j in range(1,n//i+1):
        buf += x[i*j]
    if buf!=a[i]:x[i]=1
x = x[1:]
m = 0
b = []
for i in range(n):
    if x[i]==1:
        b.append(i+1)
        m+=1
print(m)
print(*b)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    a = [None] + list(map(int, input().split()))
    b = [0]*(N+1)
    for i in range(N, 0, -1):
        ball = [b[j] for j in range(i, N+1, i)]
        if sum(ball) % 2 != a[i]:
            b[i] = 1
    print(' '.join(map(str, b[1:])))
main()

Submission status: Wrong Answer

Solution code:
N = int(input())
a = [-1]+list(map(int,input().split()))
b = [0]*(N+1)
for i in range(N,0,-1):
    su = 0
    j = 2
    while i*j <= N:
        su += a[i*j]
        j+=1
    b[i] = (a[i]+su)%2

if sum(b)>0:
    print(sum(b))
else:
    print(0)
    exit()

ans =[]
for i in range(1,N+1,1):
    if b[i]==1:
        ans.append(i)
print(*ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = [-1]+list(map(int,input().split()))
b = [0]*(N+1)
print(len(a))
for i in range(N,0,-1):
    su = 0
    j = 2
    while i*j <= N:
        su += a[i*j]
        j+=1
    b[i] = (a[i]+su)%2

if sum(b)>0:
    print(sum(b))
else:
    print(0)
    exit()

ans =[]
for i in range(1,N+1,1):
    if b[i]==1:
        ans.append(i)
print(*ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = [-1]+list(map(int,input().split()))
b = [0]*(N+1)
for i in range(N,0,-1):
    su = 0
    j = 2
    while i*j <= N:
        su += a[i*j]
        j+=1
    b[i] = (a[i]+su)%2

if sum(b)>0:
    print(sum(b))
else:
    print(0)
    exit()

ans =[]
for i in range(1,N+1,1):
    if b[i]==1:
        ans.append(i)
print(" ".join(map(str,ans)))