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()))
m = int(N/2)
b = [0]*N
for i in range(m, N):
    b[i] = a[i]
for i in range(m-1, -1, -1):
    j = i+1
    b[i] = a[i]
    while True:
        j = j*2
        if j<=N:
            b[i] += b[j-1]
        else:
            break
    b[i] = b[i]%2
print(sum(b))
if sum(b)>=1:
    for i,v in enumerate(b):
        if v==1:
            print(i+1, end=" ")

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
ball = [0 for i in range(n)]
count = 0 #ボールが入ってる箱の数
index = [] #ボールが入ってる番号

for i in range(n-1, -1, -1):
    balls = 0
    j = i
    while j +(i+1) < n:
        j += i + 1
        balls += ball[j]
    
    if a[i] != balls%2:
        a[i] = 1
        count += 1
        index.append(i+1)
        
ans = ""
for i in range(len(index)):
    if i < len(index)-1:
        ans += str(index[i]) + " "
    else:
        ans += str(index[i])
print(count)
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
cajas = list(map(int,input().split()))
ways = 0
boxes = []
for i in range(n):
    total = 0
    for j in range(i,(n//(i+1))):
        total = total+cajas[j]
    if total==cajas[i]%2 and cajas[i]!=0:
        ways+=1
        boxes.append(i+1)
if ways==0:
    print(ways)
else:
    print(ways)
    for i in range(len(boxes)):
        if i!=len(boxes)-1:
            print(boxes[i],end=" ")
        else:
            print(boxes[i])

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
import numpy as np

N = int(input())

A = list(map(int,input().split()))
B = A
ct = 0

for i in range(N):
    j = N-i-1
    if(j+1>N/2):
        B[j] = A[j]
        if(B[j]==1):
            ct = ct + 1
    else:
        for k in range(j+1,N):
            sum = 0
            if(k%(j+1)==0 and k!=j):
                sum = sum + B[k];
        if(sum%2==0):
            B[j] = A[j]
            if(B[j]==1):
                ct = ct + 1
        else:
            B[j] = 1 - A[j]
            if(B[j]==1):
                ct = ct + 1

print(ct)
C = []

for i in range(N):
    if(B[i]==1):
        C.append(i)
print(*C)

Submission status: Wrong Answer

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

b = [0 for i in range(N)]

for i in range(N)[::-1]:
    s = N // (i+1)
    a = a_list[i]
    if s > 1:
        m_a = sum([b[(i+1)*k-1] for k in range(2, s+1)]) % 2
        a = a ^ m_a
    b[i] = a
print(sum(b))

res = ""
for i in range(len(b)):
    if b[i] > 0:
        res += str(b[i]) + " "
if len(res) > 0:
    print(res)

Submission status: Wrong Answer

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

b = [0 for i in range(N)]

for i in range(N)[::-1]:
    s = N // (i+1)
    a = a_list[i]
    if s > 1:
        m_a = sum([b[i*k] for k in range(2, s+1)]) % 2
        a = a ^ m_a
    b[i] = a
print(sum(b))

res = ""
for i in range(len(b)):
    if b[i] > 0:
        res += str(b[i]) + " "
if len(res) > 0:
    print(res)

Submission status: Wrong Answer

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

b = [0 for i in range(N)]

for i in range(N)[::-1]:
    s = N // (i+1)
    a = a_list[i]
    if s > 1:
        m_a = sum([b[k] for k in range(2, s)]) % 2
        a = a ^ m_a
    b[i] = a
print(sum(b))

res = ""
for i in range(len(b)):
    if b[i] > 0:
        res += str(b[i]) + " "
if len(res) > 0:
    print(res)

Submission status: Wrong Answer

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

for i in range(n, 0, -1):
    if a[i-1] == 1:
        if n//i < 2:
            b[i-1] = 1
        else:
            c = n//i
            asums = 0
            for j in range(1, c+1):
                asums += a[j*i-1]
            if asums%2 == 1:
                b[i-1] = 1
    else:
        if n//i < 2:
            b[i-1] = 0
        else:
            c = n//i
            asums = 0
            for j in range(1, c+1):
                asums += a[j*i-1]
            if asums%2 == 1:
                b[i-1] = 1

for k in range(0, n):
    if b[k] == 1:
        l.append(k+1)

print(len(l))
print(" ".join(map(str, l)))

Submission status: Wrong Answer

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

num = len(a)
b = [0] * num

for i in reversed(range(1, num+1)):
    index = list(range(i, num+1, i))
    # print(index)
    count = 0
    for s in index:
        count += b[s-1]
    # print(count)

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

if max(b) == 0:
    print(0)
    print(0)
else:
    s = []
    for i, x in enumerate(b):
        if x == 1:
            s.append(i+1)
    print(len(s))
    print(" ".join(map(str, s)))

Submission status: Wrong Answer

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

for i in range(n, 0, -1):
    if a[i-1] == 1:
        if n//i <= 2:
            b[i-1] = 1
        else:
            c = n//i
            asums = 0
            for j in range(1, c):
                asums += a[j*i-1]
            if asums%2 == 0:
                b[i-1] = 1
    else:
        if n//i <= 2:
            b[i-1] = 0
        else:
            c = n//i
            asums = 0
            for j in range(1, c):
                asums += a[j*i-1]
            if asums%2 == 1:
                b[i-1] = 1

for k in range(0, n):
    if b[k] == 1:
        l.append(k+1)

print(len(l))
print(" ".join(map(str, l)))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
ball = [0 for i in range(n)]
count = 0
index = []

for i in range(n-1, n//2 - 1, -1):
    if a[i] == 1:
        ball[i] = 1
        count += 1
        index.append(i+1)
for i in range(n//2 - 1, -1, -1):
    if ball[i + (i+1)] % 2 != a[i]:
        ball[i] = ball[i + (i+1)] + 1
        count += 1
        index.append(i+1)
    else:
        ball[i] = ball[i + (i+1)]
        
ans = ""
for i in range(len(index)):
    if i < len(index)-1:
        ans += str(index[i]) + " "
    else:
        ans += str(index[i])
print(count)
print(ans)

Submission status: Wrong Answer

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

for i in range(n, 0, -1):
    i_sum = 0
    for j in range(i+i, n+1, i):
        i_sum += A[j]%2
    if A[i]==i_sum:
        A[i] = 0
    else:
        A[i] = 1
         
ans = [i for i, j in enumerate(A) if j]
print(len(ans))
print(*ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
ball = [0 for i in range(n)]
count = 0
index = []

for i in range(n-1, n//2 -1, -1):
    if a[i] == 1:
        ball[i] = 1
        count += 1
        index.append(i+1)
for i in range(n//2-1, -1, -1):
    if ball[i + (i+1)] % 2 != a[i]:
        ball[i] = ball[i + (i+1)] + 1
        count += 1
        index.append(i+1)
    else:
        ball[i] = ball[i + (i+1)]
        
ans = ""
for i in range(len(index)):
    if i < len(index)-1:
        ans += str(index[i]) + " "
    else:
        ans += str(index[i])
print(count)
print(ans)

Submission status: Wrong Answer

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

N = int(input())
L = [int(v) for v in input().split()]

s = {}
for i in reversed(range(N)):
    c = i + 1

    p = 0
    for v in range(c, N + 1, c):
        if s.get(v) == 1:
            p += 1

    if p % 2 != L[i]:
        s[c] = 1

if L[0] == 1 and len(s) != 1:
    print(-1)
else:
    t = []
    for k, _ in s.items():
        t.append(k)
        
    t.sort()

    print(len(t))
    print(" ".join(map(str, t)))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
ball = [0 for i in range(n)]
count = 0
index = []

for i in range(n-1, (n+1)//2 -1, -1):
    if a[i] == 1:
        ball[i] = 1
        count += 1
        index.append(i+1)
for i in range(n//2-1, -1, -1):
    if ball[i + (i+1)] % 2 != a[i]:
        ball[i] = ball[i + (i+1)] + 1
        count += 1
        index.append(i+1)
    else:
        ball[i] = ball[i + (i+1)]
        
ans = ""
for i in range(len(index)):
    if i < len(index)-1:
        ans += str(index[i]) + " "
    else:
        ans += str(index[i])
print(count)
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
ball = [0 for i in range(n)]
count = 0
index = []

for i in range(n-1, (n-1)//2 -1 , -1):
    if a[i] == 1:
        ball[i] = 1
        count += 1
        index.append(i+1)
for i in range((n-1)//2 -1, -1, -1):
    if ball[i + (i+1)] % 2 != a[i]:
        ball[i] = ball[i + (i+1)] + 1
        count += 1
        index.append(i+1)
    else:
        ball[i] = ball[i + (i+1)]
        
ans = ""
for i in range(len(index)):
    if i < len(index)-1:
        ans += str(index[i]) + " "
    else:
        ans += str(index[i])
print(count)
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
ball = [0 for i in range(n)]
count = 0
index = []

for i in range(n-1, (n-1)//2 -1 , -1):
    if a[i] == 1:
        ball[i] = 1
        count += 1
        index.append(i+1)
for i in range((n-1)//2 -1, -1, -1):
    if ball[i + (i+1)] % 2 != a[i]:
        ball[i] = ball[i + (i+1)] + 1
        count += 1
        index.append(i+1)
        
ans = ""
for i in range(len(index)):
    if i < len(index)-1:
        ans += str(index[i]) + " "
    else:
        ans += str(index[i])
print(count)
print(ans)

Submission status: Wrong Answer

Solution code:
import sys

N=int(sys.stdin.readline().rstrip())
AList=list(map(int,sys.stdin.readline().split()))

bList=[]
ansList=[]
for i in range(len(AList)-1, -1, -1):
  sumb=sum(bList[::i+1])%2
  if (sumb==AList[i]):
    bList.insert(0, 0)
  else:
    bList.insert(0, 1)
    ansList.append(i+1)

if len(ansList) == 0:
    print(0)
    exit() 
else:
  print(len(ansList))
  for ans in ansList:
    print(ans)

Submission status: Wrong Answer

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

for i in range(n, 0, -1):
    if a[i-1] == 1:
        if n//i < 2:
            b[i-1] = 1
        else:
            c = n//i
            asums = 0
            for j in range(1, c):
                asums += a[j*i-1]
            if asums%2 == 0:
                b[i-1] = 1
    else:
        if n//i < 2:
            b[i-1] = 0
        else:
            c = n//i
            asums = 0
            for j in range(1, c):
                asums += a[j*i-1]
            if asums%2 == 1:
                b[i-1] = 1

for k in range(0, n):
    if b[k] == 1:
        l.append(k+1)

print(len(l))
print(" ".join(map(str, l)))

Submission status: Wrong Answer

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

for i in range(n, 0, -1):
    if a[i-1] == 1:
        if n//i < 2:
            b[i-1] = 1
        else:
            c = n//i
            asums = 0
            for j in range(1, c):
                asums += a[j*(i-1)]
            if asums%2 == 0:
                b[i-1] = 1
    else:
        if n//i < 2:
            b[i-1] = 0
        else:
            c = n//i
            asums = 0
            for j in range(1, c):
                asums += a[j*(i-1)]
            if asums%2 == 1:
                b[i-1] = 1

for k in range(0, n):
    if b[k] == 1:
        l.append(k+1)

print(len(l))
print(" ".join(map(str, l)))

Submission status: Wrong Answer

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

for i in reversed(range(n)):
    for j in range(i + 1, n, i + 1):
        x = 1
        k = j
        while k < n:
            x ^= b[k]
            k += j
        if x == a[i]:
            b[i] = 1

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

Submission status: Wrong Answer

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

for i in reversed(range(n)):
    for j in range(i + 1, n, i + 1):
        x = 1
        k = j
        while k < n:
            x ^= b[i]
            k += j
        if x == a[i]:
            b[i] = 1

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

Submission status: Wrong Answer

Solution code:
n = int(input())
a_array = [int(x) for x in input().split()]
ans_array = [0 for x in range(n)]
for index in reversed(range(1, n + 1)):
    if index > n // 2:
        ans_array[index - 1] = a_array[index - 1]
    elif index - 1 != 0:
        tmp = sum([ans_array[x] for x in range(index * 2 - 1, n, index) if ans_array[x] != 0])
        if tmp % 2 == a_array[index - 1]:
            pass
        else:
            # tmpが0だったら1、1だったら0になるように
            ans_array[index - 1] = 1 - tmp % 2

    else:
        tmp = sum([x for x in ans_array[1:] if x != 0])
        if tmp % 2 == a_array[index - 1]:
            pass
        else:
            # tmpが0だったら1、1だったら0になるように
            ans_array[index - 1] = 1 - tmp % 2
print(sum([x for x in ans_array if x != 0]))
for index, ans in enumerate(ans_array, 1):
    if ans != 0:
        print(index)

Submission status: Wrong Answer

Solution code:
n = int(input())
a_array = [int(x) for x in input().split()]
ans_array = [0 for x in range(n)]
for index in reversed(range(1, n + 1)):
    if index > n // 2:
        ans_array[index - 1] = a_array[index - 1]
    elif index - 1 != 0:
        tmp = sum([ans_array[x] for x in range(index * 2 - 1, n, index) if ans_array[x] != 0])
        if tmp % 2 == a_array[index - 1]:
            pass
        else:
            # tmpが0だったら1、1だったら0になるように
            ans_array[index - 1] = 1 - tmp % 2

    else:
        tmp = sum([x for x in ans_array[1:] if x != 0])
        if tmp % 2 == a_array[index - 1]:
            pass
        else:
            # tmpが0だったら1、1だったら0になるように
            ans_array[index - 1] = 1 - tmp % 2
for index, ans in enumerate(ans_array, 1):
    if ans != 0:
        print(index)

Submission status: Wrong Answer

Solution code:
N = int(input())
L = [0] + list(map(int,input().split()))
N = len(L)
ans = [0 for i in range(N + 2)]
for i in reversed(range(1,N)):
    cnt = 0
    c = i
    while True:
        c += i
        if c > N:
            break
        cnt += ans[c]
    if cnt % 2 == 0 and L[i] == 0:
        ans[i] = 0
    elif cnt % 2 == 0 and L[i] == 1:
        ans[i] = 1
    elif cnt % 2 == 1 and L[i] == 0:
        ans[i] = 1
    else:
        ans[i] = 0 
c = 0
for i in range(len(ans)):
    if ans[i] == 1:
        c = i
ans = ans[1:c+1]

cnt = 0
for x in ans:
    if x == 1:
        cnt += 1
print(cnt)
for i in range(len(ans)):
    if x == 1:
        print(i+1,end = ' ')

Submission status: Wrong Answer

Solution code:
N = int(input())
L = [0] + list(map(int,input().split()))
N = len(L)
ans = [0 for i in range(N + 2)]
for i in reversed(range(1,N)):
    cnt = 0
    c = i
    while True:
        c += i
        if c > N:
            break
        cnt += ans[c]
    if cnt % 2 == 0 and L[i] == 0:
        ans[i] = 0
    elif cnt % 2 == 0 and L[i] == 1:
        ans[i] = 1
    elif cnt % 2 == 1 and L[i] == 0:
        ans[i] = 1
    else:
        ans[i] = 0 
c = 0
for i in range(len(ans)):
    if ans[i] == 1:
        c = i
ans = ans[1:c+1]

cnt = 0
for x in ans:
    if x == 1:
        cnt += 1
print(cnt)
for _ in range(cnt):
    print(1,end=' ')

Submission status: Wrong Answer

Solution code:
N = int(input())
L = [0] + list(map(int,input().split()))
N = len(L)
ans = [0 for i in range(N + 2)]
for i in reversed(range(1,N)):
    cnt = 0
    c = i
    while True:
        c += i
        if c > N:
            break
        cnt += ans[c]
    if cnt % 2 == 0 and L[i] == 0:
        ans[i] = 0
    elif cnt % 2 == 0 and L[i] == 1:
        ans[i] = 1
    elif cnt % 2 == 1 and L[i] == 0:
        ans[i] = 1
    else:
        ans[i] = 0 
c = 0
for i in range(len(ans)):
    if ans[i] == 1:
        c = i
ans = ans[1:c+1]

print(len(ans))

for x in ans:
    print(x,end = ' ')

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()))
B = [0]*N
put = []

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


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

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()))
B = [0]*N
put = []

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


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

Submission status: Wrong Answer

Solution code:
n = int(input())
a_array = [int(x) for x in input().split()]
ans_array = []
for a in a_array:
    ans_array.append(a)
print(sum([x for x in ans_array if x != 0]))
for index, ans in enumerate(ans_array, 1):
    if ans != 0:
        print(index)

Submission status: Wrong Answer

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

l = []
for i in range(1, n + 1):
  if 2 * i <= n:
    if a[i - 1] != a[2 * i - 1]:
      l.append(str(i))
  else:
    if a[i - 1] == 1:
      l.append(str(i))

print(len(l))
print(' '.join(l))

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していく
        tmp = 1
        n = i+1
        while tmp*tmp <= n:
            if n % tmp == 0:
                A[tmp-1] ^= 1
            tmp += 1


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

Submission status: Wrong Answer

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

    b = [0] * N

    for i in range(N-1,-1,-1):
        sum = 0
        for j in range(2*(i+1), N, i+1):
            sum += b[j]
        if sum % 2 != a[i] % 2:
            b[i] = 1
    ans = []
    for i in range(N):
        if b[i] == 1:
            ans.append(i+1)
    
    print(len(ans))
    if ans: 
        print(*ans)

main()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

import sys
from math import sqrt

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

def divisor_set(N: int) -> set:
    """ 約数の列挙・個数 """
    # 1とその数はデフォで入れとく
    s = {1, N}
    # 終点はルート切り捨て
    for i in range(2, int(sqrt(N))+1):
        # 割り切れるなら、iとN/iを追加
        if N % i == 0:
            s.add(i)
            s.add(N // i)
    return s

N=INT()
A=LIST()

A2=[0]*N
for i in range(N-1, -1, -1):
    if A[i]!=A2[i]:
        div=divisor_set(i+1)
        for num in div:
            A2[num-1]=1-A2[num-1]

B=[]
for i in range(N):
    if A2[i]==1:
        B.append(i+1)
print(len(B))
print(*B)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

import sys
from math import sqrt

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

def divisor_set(N: int) -> set:
    """ 約数の列挙・個数 """
    # 1とその数はデフォで入れとく
    s = {1, N}
    # 終点はルート切り捨て
    for i in range(2, int(sqrt(N))+1):
        # 割り切れるなら、iとN/iを追加
        if N % i == 0:
            s.add(i)
            s.add(N // i)
    return s

N=INT()
A=LIST()

A2=[0]*N
for i in range(N-1, -1, -1):
    if A[i]==1 and A2[i]!=1:
        div=divisor_set(i+1)
        for num in div:
            A2[num-1]=1-A2[num-1]

B=[]
for i in range(N):
    if A2[i]==1:
        B.append(i+1)
print(len(B))
print(*B)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

import sys
from math import sqrt

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

def divisor_set(N: int) -> set:
    """ 約数の列挙・個数 """
    # 1とその数はデフォで入れとく
    s = {1, N}
    # 終点はルート切り捨て
    for i in range(2, int(sqrt(N))+1):
        # 割り切れるなら、iとN/iを追加
        if N % i == 0:
            s.add(i)
            s.add(N // i)
    return s

N=INT()
A=LIST()

A2=[0]*N
for i in range(N-1, -1, -1):
    if A[i]==1 and A2[i]!=1:
        div=divisor_set(i+1)
        for num in div:
            A2[num-1]=1-A2[num-1]

B=[]
for i in range(N):
    if A2[i]==1:
        B.append(i+1)
print(*B)

Submission status: Wrong Answer

Solution code:

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

M = 0
ans_lst = [0] * N

t = 0
for i in range(N-1, -1, -1):
    t = 0
    for j in range(2*i, N, i+1):
        t += ans_lst[j]
        
    if (t + 1) % 2 == a_lst[i]:
        ans_lst[i] = 1
    


m = 0
for i in range(N):
    m += ans_lst[i]
    


print(m)
ans_str = ""
for i in range(N):
    if ans_lst[i] == 1:
        if i != 0:
            ans_str += " "
        ans_str += str(i+1)
print(ans_str)

Submission status: Wrong Answer

Solution code:
N = int(input())
num_line = [0] + list(map(int, input().split()))
for i in range(N//2, 0, -1):
    #num_line[i] = sum(num_line[i::i]) % 2
    if sum(num_line[i::i]) % 2 != num_line[i]:
        num_line[i] = 1
    else:
        num_line[i] = 0
print(num_line.count(1))
print(" ".join(map(str, list(i for i in range(1, N+1) if num_line[i] == 1))))

Submission status: Wrong Answer

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

ans = 0
ans2 = []

for num, val in list(enumerate(b))[::-1]:
    if not ans % 2 == val:
        ans ^= 1
        ans2.append(str(num+1))
print(ans)
if len(ans2):
    print(' '.join(ans2))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,a,d,l=int(input()),list(map(int,input().split())),set(),0;b=[0]*n
for i in range(n-1,-1,-1):
  c=0
  for j in range(2*i+1,n,i+1):c=(c+b[j])%2
  if a[i]!=c:b[i]+=1;d.add(i+1);l+=1
print(*[d.pop()for _ in range(l)])

Submission status: Wrong Answer

Solution code:
n,a,d,l=int(input()),list(map(int,input().split())),set(),0;b=[0]*n
for i in range(n-1,-1,-1):
  c=0
  for j in range(2*i+1,n,i+1):c=(c+b[j])%2
  if a[i]!=c:b[i]+=1;d.add(i+1);l+=1
  print(c,i+1)
print(l)
print(*[d.pop()for _ in range(l)])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,a,d,l=int(input()),list(map(int,input().split())),set(),0;b=[0]*n
for i in range(n-1,-1,-1):
  c=0
  for j in range(2*i+1,n//(i+1),i+1):c=(c+b[j])%2
  if a[i]!=c:b[i]+=1;d.add(i+1);l+=1
print(l)
print(*[d.pop()for _ in range(l)])

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
b=[0 for i in range(n)]
c=0
d=0
for i in range(n-1,-1,-1):
  j=2
  c=b[i]
  while((i+1)*j<=n):
    c=c^b[(i+1)*j-1]
    j+=1
  if (c!=a[i]):
    b[i]=1
  c=0
  j=2
print('{0}'.format(sum(b)))
e=list(map(str,b))
e=[i for i in e if i=='1']
f=' '.join(e)
print('{0}'.format(f))

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
b=[0 for i in range(n)]
c=0
d=0
for i in range(n-1,-1,-1):
  j=2
  c=b[i]
  while((i+1)*j<=n):
    c=c^b[(i+1)*j-1]
    j+=1
  if (c!=a[i]):
    b[i]=1
  j=2
print('{0}'.format(sum(b)))
e=list(map(str,b))
e=[i for i in e if i=='1']
f=' '.join(e)
print('{0}'.format(f))

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
b=[0 for i in range(n)]
c=0
d=0
for i in range(n-1,-1,-1):
  j=1
  c=b[i]
  while((i+1)*j<=n):
    c=c^b[(i+1)*j-1]
    j+=1
  if (c!=a[i]):
    b[i]=1
print('{0}'.format(sum(b)))
e=list(map(str,b))
e=[i for i in e if i=='1']
f=' '.join(e)
print('{0}'.format(f))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ans = [0 for _ in range(N)]
for i in range(N-1, -1, -1):
    if sum(ans[i+1::i+1]) % 2 == inputs[i]:
        ans[i] = 0
    else:
        ans[i] = 1

if ans.count(1) == 0:
    print(0)
else:
    print(ans.count(1))
    result = ''
    for i in range(N):
        if ans[i] == 1:
            result += str(i+1) + ' '
    print(result)

Submission status: Wrong Answer

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

ans = [0 for _ in range(N)]
for i in range(N-1, -1, -1):
    if sum(ans[::i+1]) % 2 == inputs[i]:
        ans[i] = 0
    else:
        ans[i] = 1

if ans.count(1) == 0:
    print(0)
else:
    print(ans.count(1))
    result = ''
    for i in range(N):
        if ans[i] == 1:
            result += str(i+1) + ' '
    print(result)

Submission status: Wrong Answer

Solution code:
N = int(input())
num_line = [0] + list(map(int, input().split()))
for i in range(N, 1, -1):
    if sum(num_line[i::i]) != num_line[i]:
        num_line[i] = 1
print(num_line.count(1))
print(" ".join(map(str, list(i for i in range(1, N) if num_line[i] == 1))))
print()

Submission status: Wrong Answer

Solution code:
N = int(input())
num_line = [0] + list(map(int, input().split()))
for i in range(N, 1, -1):
    if sum(num_line[i::i]) != num_line[i]:
        num_line[i] = 1
print(num_line.count(1))
print(" ".join(map(str, list(i for i in range(1, N) if num_line[i] == 1))))

Submission status: Wrong Answer

Solution code:
N = int(input())
num_line = [0] + list(map(int, input().split()))
count = 0
for i in range(N, 1, -1):
    if sum(num_line[i::i]) != num_line[i]:
        num_line[i] = 1
        count += 1
print(num_line.count(1))
print(" ".join(map(str, [i for i in range(1, N) if num_line[i] == 1])))

Submission status: Wrong Answer

Solution code:
import sys
# input = sys.stdin.readline
inf = 10 ** 18
P = 10 ** 9 + 7

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

x = [ai % 2 for ai in a]
for i_inv in range(N):
    i = (N - 1) - i_inv
    j = 2
    xi = x[i]
    while (i + 1) * j < N:
        xi ^= x[(i + 1) * j - 1]
        j += 1
    x[i] = xi

print(sum(x))
ans = []
for i, xi in enumerate(x):
    if xi == 1:
        ans.append(i + 1)

if sum(x) > 0:
    print(' '.join(map(str, ans)))

Submission status: Wrong Answer

Solution code:
import sys
# input = sys.stdin.readline
inf = 10 ** 18
P = 10 ** 9 + 7

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

x = [None] * N
for i_inv in range(N):
    i = (N - 1) - i_inv
    j = 2
    xi = a[i] % 2
    while (i + 1) * j < N:
        xi ^= x[(i + 1) * j - 1]
        j += 1
    x[i] = xi

print(sum(x))
ans = []
for i, xi in enumerate(x):
    if xi == 1:
        ans.append(i + 1)

if sum(x) > 0:
    print(' '.join(map(str, ans)))

Submission status: Wrong Answer

Solution code:
import sys
# input = sys.stdin.readline
inf = 10 ** 18
P = 10 ** 9 + 7

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

x = [None] * N
for i_inv in range(N):
    i = (N - 1) - i_inv
    j = 2
    xi = a[i] % 2
    while (i + 1) * j < N:
        xi ^= x[(i + 1) * j - 1]
        j += 1
    x[i] = xi

print(sum(x))
ans = []
for i, xi in enumerate(x):
    if xi == 1:
        ans.append(i + 1)

if sum(x) < 0:
    print(' '.join(map(str, ans)))