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: Accepted

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

i=n-1
while i>=0:
    if A[i]==1:
        s=i
        break
    i-=1

if i==-1:
    print(0)
elif s==0:
    print(1)
    print(1)
else:
    i=(s+1)//2-1
    while i>=0:
        B=[A[j] for j in range(i,n,i+1)]
        r=sum(B[1:])
        if r%2==0 and A[i]==0:
            A[i]=0
        elif r%2==0 and A[i]==1:
            A[i]=1
        elif r%2==1 and A[i]==0:
            A[i]=1
        else:
            A[i]=0
        i-=1
    C=[m for m,k in enumerate(A,1) if k!=0]
    print(len(C))
    print(*C)

Submission status: Accepted

Solution code:
N=int(input())
A=list(map(int,input().split()))
B=[]
#N-1から-1まで逆順に
for i in range(N-1,-1,-1):
  #iスタートから終わるまで、（i+1）ずつ加算
  #3（A[2]）,6,9…
  A[i]=(sum(A[i::i+1])%2)&1
  
B=[i+1 for i in range(N) if A[i]]
print(len(B))
if len(B)>0:
  print(*B)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
input = sys.stdin.readline

n = int(input())
a = list(map(int,input().split()))
ret = [0 for _ in range(n+1)]
#後ろから求める
for i,a_i in enumerate(a[-1::-1]):
    cur_ret_sum = sum(ret[n-i::n-i])%2
    if a_i!=cur_ret_sum:
        ret[n-i]=1
m = sum(ret[1::])
print(m)
if m > 0:
    print(" ".join([str(i) for i,v in enumerate(ret) if v==1]))

Submission status: Accepted

Solution code:
N = int(input())
Data = list(map(int,input().split()))
Ans  = [0]*N
Ans2 = [0]*N

for n in range(N,0,-1):
    Ans[n-1] = Data[n-1]
    k = 2
    while k*n <= N:
        Ans[n-1] -= Ans[k*n-1]
        if Ans[n-1] < 0:
            Ans[n-1] = 1
        k+=1

cnt = 0
for i in range(N):
    if Ans[i] == 1:
        Ans2[cnt] = i+1 
        cnt += 1

print(cnt)
if cnt > 0:
    for i in range(cnt):
        print( Ans2[i], end = ' ')
    print()

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    A = tuple(map(int, input().split()))
    l = [0] * N
    for i in range(N, 0, -1):
        t = 0
        for j in range(i, N+1, i):
            t += l[j-1]
        l[i-1] = abs(A[i-1] - (t % 2))
    print(sum(l))
    l2 = [i + 1 for i, j in enumerate(l) if j == 1]
    print(' '.join([str(i) for i in l2]))
main()

Submission status: Accepted

Solution code:
n = int(input())
A = list(map(int, input().split()))
B = []
S = [0]*n
for i in range(n-1, -1, -1):
  if sum(S[i::i+1])%2 ^ A[i]:
    B.append(i+1)
    S[i] ^= 1
print(len(B))
print(*B)

Submission status: Accepted

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

ans = []

for i in range(N-1, -1, -1):
  A[i] = sum(A[i::i+1]) & 1

ans = [i + 1 for i in range(N) if A[i]]

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

Submission status: Accepted

Solution code:
def calculate(arr):
    N = len(arr)
    index = N - 1

    result = [0]*N
    result2 = []

    while index >= 0:

        if N // (index+1) > 1:
            v1 = calculate2(N // (index+1),index,result)

            if arr[index] % 2 == 0:
                if v1 % 2 == 0:
                    pass
                else:
                    result[index] = 1
                    result2.append(index + 1)
            else:
                if v1 % 2 == 0:
                    result[index] = 1
                    result2.append(index + 1)
                else:
                    pass

        else:
            if arr[index] == 0:
                result[index] = 0
            else:
                result[index] = 1
                result2.append(index + 1)

        index = index - 1

    return result,result2


def calculate2(len, base, arr):
    result = 0
    for i in range(2, len+1):
        result += arr[(base + 1) * i - 1]
    return result


N = int(input())
S = input().split(" ")
arr = [int(s) for s in S]

result, result2 = calculate(arr)

print(sum(result))
if len(result2) > 0:
    print(" ".join([str(s) for s in result2]))

Submission status: Accepted

Solution code:
n=int(input())
a=list(map(int,input().split()))
ans = [0]*n
an=[]
for i in range(n-1,-1,-1):
	now = i
	cnt=0
	while(now<n):
		cnt+=ans[now]
		now+=i+1
	ans[i] = a[i]^(cnt%2)
	if ans[i]:
		an.append(i+1)
an.reverse()
print(sum(ans))
print(" ".join([str(x)for x in an]))

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int, input().split()))
B = [False] * N
for i in range(N, 0, -1):
    B[i-1] = (A[i-1] + sum(B[j-1] for j in range(i * 2, N+1, i))) & 1
C = [i for i, a in enumerate(B, 1) if a]
print(len(C))
print(*C)

Submission status: Accepted

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

for i in reversed(range(1, n + 1)):
    k = i
    cnt = 0
    while k <= n:
        cnt += b[k]
        k += i

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

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

Submission status: Accepted

Solution code:
import sys

import numpy as np

readline = sys.stdin.buffer.readline


def main():
    N = int(readline())
    A = [0] + list(map(int, readline().split()))
    A = np.array(A)
    C = np.zeros(N + 1, dtype=np.int32)

    if A[-1] == 1:
        C[-1] == 1

    for j in range(N, 0, -1):
        cnt = np.count_nonzero(C[j::j])
        C[j] = (cnt % 2) ^ A[j]

    ans = np.sum(C)
    print(ans)
    if ans != 0:
        B = np.arange(N + 1)
        li = B[C == 1]
        print(*li, sep='\n')


main()

Submission status: Accepted

Solution code:
N=int(input())
A=[int(i) for i in input().split()]
B=[0 for _ in range(N)]
def f(a,N):
    l=[]
    m=2*a
    while m<=N:
        l.append(m)
        m+=a
    return l

for a in range(1,N+1)[::-1]:
    idx=f(a,N)
    b_sum=0
    for i in idx:
        b_sum += B[i-1]
    B[a-1] = (A[a-1] - b_sum) % 2
ans=[i+1 for i in range(N) if B[i] != 0]
print(len(ans))
if len(ans)!=0:
    print(*ans)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

N = int(input())
a = [int(i) for i in input().split()]

box = [0] * N

for i in range(N-1, -1, -1):
    # (i+1)の倍数が書かれた箱を探索
    count = 0
    n = i+1
    while n <= N:
        count += box[n-1]
        n += i + 1

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

M = box.count(1)
print(M)

answer = [i+1 for i,x in enumerate(box) if x == 1]
if M > 0:
    print(' '.join(list(map(str,answer))))

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    a_list = [-1]
    a_list += list(map(int, input().split()))

    bolls = [0] * (n + 1)
    m = 0
    for i in range(n, 0, -1):
        count = 0
        for j in range(2, n + 1):
            multiple = i * j
            if multiple > n:
                break
            else:
                count += bolls[multiple]
        temp = count % 2
        if a_list[i] != temp:
            bolls[i] = 1
            m += 1

    print(m)
    ans_list = []
    for i in range(1, n + 1):
        if bolls[i] >= 1:
            ans_list.append(i)
    print(' '.join(map(str, ans_list)))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())
a = [0]
a += list(map(int, input().split()))
ans = [0]*(N+1)
for i in range(N, 0, -1):
    if i > N/2:
        ans[i] = a[i]
    elif i == 1:
        cnt = sum(ans)
        ans[i] = (a[i] + cnt) % 2
    else:
        num = N // i
        cnt = 0
        for j in range(2, num+1):
            cnt += ans[i * j]
        ans[i] = (a[i] + cnt) % 2

print(sum(ans))
s = ""
for i in range(N+1):
    if ans[i] == 1:
        s += str(i) + " "
print(s)

Submission status: Accepted

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

for i in range(n, 0, -1):
    t_sum = 0
    j = 2 * i
    while j <= n:
        t_sum ^= b[j]
        j += i
    b[i] = t_sum ^ a[i]
print(sum(b[1:]))
for i in range(1, n + 1):
    if b[i] != 0:
        print(i, end = ' ')

Submission status: Accepted

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


def main():
    n = int(input())
    a = [int(_) for _ in input().split()]
    l = [0 for _ in range(n)]
    for i in range(n-1, -1, -1):
        re_i = i + 1
        res = 0
        for j in range(0, n//re_i):
            re_j = j + 1
            res += l[(re_i * re_j) - 1]
        if res % 2 != a[i]:
            l[i] = 1
    ans = []
    for i in range(len(l)):
        if l[i] == 1:
            ans.append(i + 1)
    print(len(ans))
    if len(ans) == 0:
        sys.exit()
    else:
        print(" ".join(map(str, ans)))
            


if __name__ == '__main__':
    main()

Submission status: Accepted

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


def main():
    n = int(input())
    a = [int(_) for _ in input().split()]
    l = [0 for _ in range(n)]
    for i in range(n-1, -1, -1):
        re_i = i + 1
        # print('re_i', re_i)
        res = 0
        for j in range(0, n//re_i):
            re_j = j + 1
            # print('re_j', re_j)
            # print('たすidx', (re_i * re_j) - 1)
            res += l[(re_i * re_j) - 1]
        # print('res', res)
        if res % 2 != a[i]:
            l[i] = 1
        # print('l', l)
    ans = []
    for i in range(len(l)):
        if l[i] == 1:
            ans.append(i + 1)
    print(len(ans))
    if len(ans) == 0:
        sys.exit()
    else:
        print(" ".join(map(str, ans)))
            


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
a = list(map(int, input().split()))
b = [0] * N
for i in range(N, 0, -1):
    sum = 0
    for j in range(i*2, N+1, i):
        sum += b[j-1]
    if sum % 2 == 0:
        b[i-1] = a[i-1]
    else:
        b[i-1] = 1 - a[i-1]
count = b.count(1)
print(b.count(1))
if count > 0:
    ans = ''
    for i in range(1, N+1):
        if b[i-1] == 1:
            ans += str(i) + ' '
    print(ans[:-1])

Submission status: Accepted

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

a = [0] + a
b = [0] * (n+1)

for i in range(n, 0, -1):
    sum = 0
    for j in range(i, n+1, i):
        sum ^= b[j]
    b[i] = sum^a[i]


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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import stdin

n = int(stdin.readline().rstrip())
li = [0] + list(map(int,stdin.readline().rstrip().split()))
lin = [0]*(n+1)
point = 0
lis = []

for i in range(n,0,-1):
    su = sum(lin[i::i])%2
    if li[i] != su:
        lin[i] = 1
        point += 1
        lis.append(i)
    
print(point)
lis.sort()

for i in lis:
    print(i)

Submission status: Accepted

Solution code:
import sys
n = int(input())
a = list(map(int, input().split()))
b = [0 for _ in range(n)]

for i in range(n) :
  j = n - (i+1)
  if j == 0 :
    if a[0] == 1 and sum(b)%2 == 0 :
      b[0] = 1
    if a[0] == 0 and sum(b)%2 == 1 :
      b[0] = 1
  elif n//(j+1) == 1 :
    if a[j] == 1 :
      b[j] = 1
  else :
    k = 2
    b_sum = 0
    while n >= k*(j+1) :
      b_sum += b[k*(j+1)-1]
      k += 1
    if a[j] == 1 and b_sum%2 == 0 :
      b[j] = 1
    if a[j] == 0 and b_sum%2 == 1 :
      b[j] = 1
      
print(sum(b))

ans = []
if sum(b) != 0 :
  for i in range(n) :
    if b[i] == 1 :
      ans.append(str(i+1))
  print(*ans)

Submission status: Accepted

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

ans=set()
for i in range(n-1,-1,-1):
  for j in range(i+1,n+1,i+1):
    if j in ans:
      A[i]+=1
  if A[i]%2:
    ans.add(i+1)
print(len(ans))
print(*ans)

Submission status: Accepted

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

M = 0
boxes = [0]*N
for i in reversed(range(N)):
    num_balls = 0
    for k in range(i, N, i+1):
        num_balls += boxes[k]
    if num_balls%2 != a[i]:
        boxes[i] = 1
        M += 1

print(M)
for i in range(N):
    if boxes[i]==1:
        print(i+1)

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int, input().split()))
M = 0
B = [0]*N
for i in reversed(range(N)):
    tmp = 0
    for k in range(i, N, i+1):
        tmp += B[k]
    if tmp % 2 != A[i]:
        B[i] = 1
        M += 1
print(M)
for i in range(N):
    if B[i] == 1:
        print(i+1)

Submission status: Accepted

Solution code:
#coding: utf-8
import math
import heapq
import bisect

MOD = 10**9+7

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

B = [0]*(N+1)
for i in reversed(range(1,N+1)):
    k = i
    cnt = 0
    while k <= N:
        cnt += B[k]
        k += i
    
    if cnt%2 != A[i]:
        B[i] = 1

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

Submission status: Accepted

Solution code:
N = int(input())
nums = [0 for _ in range(N+1)]
A = list(map(int, input().split(' ')))
A.insert(0, 0)

for i in range(N, 0, -1):
    s = sum([nums[j] for j in range(i, N+1, i)])
    if s % 2 != A[i]:
        nums[i] = 1

print(sum(nums))
print(' '.join([str(i) for i, num in enumerate(nums) if num == 1]))

Submission status: Accepted

Solution code:
N = int(input())
a = list(map(int,input().split()))
a = [-1] + a
count = 0

for i in range(N//2, 0, -1):
    d = N//i
    for j in range(2,d+1):
        count += a[i*j]
    if a[i] % 2 != count % 2:
        a[i] = 1
    else:
        a[i] = 0
    count = 0
print(sum(a)+1)
for i in range(1,N+1):
    if a[i] == 1:
        print(i, end=' ')

Submission status: Accepted

Solution code:
N=int(input())
A=list(map(int,input().split()))
B=[0 for i in range(N)]
M=0
C_list=[]

for n in range(N,0,-1):
    K=N//(n)
    for m in range(K):
        if m==0:
            B[n-1]+=A[n-1]
        else:
            B[n-1]+=B[n-1+n*m]
    B[n-1]%=2
    if B[n-1]:
        C_list.append(n)
    M+=B[n-1]

S=" ".join(list(map(str,reversed(C_list))))
print(M)
print(S)

Submission status: Accepted

Solution code:
N = int(input())
a = list(map(int, input().split()))
 
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors
 
 
tmp = [0]*(N+1)
b = [0]*N
ball_num = 0
ball_box = []
for i in reversed(range(N)):
    if a[i] == 0:
        if (tmp[i+1]%2) == 0:
            continue
        else:
            ball_box.append(i+1)
            ball_num += 1
            val = make_divisors(i+1)
            for elms in val:
                tmp[elms] += 1
    elif a[i] == 1:
        if (tmp[i+1]%2) == 0:
            ball_box.append(i+1)
            ball_num += 1
            val = make_divisors(i+1)
            for elms in val:
                tmp[elms] += 1
        else:
            continue
 
print(ball_num)
if ball_num != 0:
    print(*ball_box)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline

def main(): 
    N = int(input())
    A = [0] + list(map(int, input().split()))
    
    ans = [0] * (N+1)
    c = 0
    for i in range(N, 0, -1):
        t = sum(ans[i::i])
            
        if A[i] != (t%2): 
            ans[i] = 1
            c += 1
            
    print(c)
    for idx, n in enumerate(ans): 
        if n: print(idx, '', end='')

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n=int(input())
A=list(map(int,input().split()))
B,C=[0 for i in range(n+1)],[]
cnt=0
for i in range(1,n+1)[::-1]:
    sum_list=sum([B[j] for j in range(i,n+1,i)])
    if sum_list%2!=A[i-1]:
        B[i]=1
        cnt +=1
        C.append(i)
print(cnt)
print(*[i for i in C[::-1]])

Submission status: Accepted

Solution code:
n = int(input())
a = [num for num in map(int, input().split(' '))]

# print(n, a)

ans = [0] * (n+1)

for i in range(n):
  # 後ろから走査するための index
  target_i = n - i
  a_targt = a[n-i-1]
  
  # a の倍数の箱のボールの個数を計算
  baisu = 2
  ball_count = 0
  while True:
    baisu_i = target_i * baisu
    if baisu_i > n:
      break
    if ans[baisu_i] == 1:
      ball_count += 1
    baisu += 1
  # 倍数の箱のボールの総数 % 2 が a[i]と異なる場合、箱にボールを入れる必要がある
  if ball_count % 2 != a_targt:
    ans[target_i] = 1

ans_array = []

for i in range(1, n+1):
  if ans[i] == 1:
    ans_array.append(i)
print(len(ans_array))
if len(ans_array) > 0:
  print(' '.join(map(str, ans_array)))
# print(ans)

Submission status: Accepted

Solution code:
n=int(input())
A=list(map(int,input().split()))
B,C=[0 for i in range(n+1)],[]
cnt=0
for i in range(1,n+1)[::-1]:
    sum_B=sum(B[j] for j in range(i,n+1,i))
    if sum_B%2!=A[i-1]:
        B[i]=1
        cnt +=1
        C.append(i)
print(cnt)
print(*[i for i in C[::-1]])

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split()))
c = [0]
d = c + a
s = [0 for i in range(n + 1)]

for i in range(n, 0, -1):
    w = 0
    for j in range(2 * i, n + 1, i):
        w ^= s[j]
    s[i] = w ^ d[i]

print(sum(s))
for i in range(1, n + 1):
    if s[i]:
        print(i,end=' ')

Submission status: Accepted

Solution code:
n=int(input())
A=list(map(int,input().split()))
B=[0 for i in range(n+1)]
C=[]
cnt=0
for i in range(1,n+1)[::-1]:
    sum_B=sum(B[j] for j in range(i,n+1,i))
    if sum_B%2!=A[i-1]:
        B[i]=1
        C.append(i)
        cnt +=1
print(cnt)
print(*[i for i in C[::-1]])

Submission status: Accepted

Solution code:
N = int(input())
A = list(map(int, input().split()))
b = [0 for _ in range(N)]
for i in range(N, 0, -1):
    b[i-1] = 0 if sum(b[i-1::i]) % 2 == A[i-1] else 1
ans = [str(i+1) for i, x in enumerate(b) if x == 1]
print(len(ans))
if ans:
    print(' '.join(ans))

Submission status: Accepted

Solution code:
# 2019-11-15 14:12:24(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
# from functools import reduce
# import operator as op
# import re
# from scipy.misc import comb # float
# import numpy as np 

def main():
    n, *a = [int(x) for x in sys.stdin.read().split()]
    a = [None] + a

    in_or_not = [0 for _ in range(n+1)]
    for i in range(n, 0, -1):
        count = sum(in_or_not[2*i:n+1:i])  
        in_or_not[i] = a[i] ^ count % 2
    
    print(in_or_not.count(1))
    for i in range(1, n+1):
        if in_or_not[i] == 1:
            print(i, end=' ')


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
# 2019-11-15 14:12:24(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
# from functools import reduce
# import operator as op
# import re
# from scipy.misc import comb # float
# import numpy as np 

def main():
    n, *a = [int(x) for x in sys.stdin.read().split()]
    a = [None] + a

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

    print(in_or_not.count(1))
    for i in range(1, n+1):
        if in_or_not[i] == 1:
            print(i, end=' ')




if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
# 2019-11-15 14:12:24(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
# from functools import reduce
# import operator as op
# import re
# from scipy.misc import comb # float
# import numpy as np 

def main():
    n, *a = [int(x) for x in sys.stdin.read().split()]
    a = [None] + a

    in_or_not = [0 for _ in range(n+1)]
    for i in range(n, 0, -1):
        count = 0
        for j in range(2 * i, n+1, i):
            count += in_or_not[j]
        if a[i] == 1:
            if count % 2 == 0:
                in_or_not[i] = 1
        else:
            if count % 2 == 1:
                in_or_not[i] = 1
    

    print(in_or_not.count(1))
    for i in range(1, n+1):
        if in_or_not[i] == 1:
            print(i, end=' ')




if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n = int(input())
a = [0] + list(map(int, input().split()))
ans = [0] * (n+1)
for i in range(n,0,-1):
  SUM = 0
  for j in range(i,n+1,i):
    SUM += ans[j]
  ans[i] = (SUM + a[i]) % 2
m = 0
b = []
for key,i in enumerate(ans):
  if i:
    m += 1
    b.append(key)
print(m)
print(*b)

Submission status: Accepted

Solution code:
import sys

read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs = sys.stdin.buffer.readlines


# rstrip().decode('utf-8')
# INF=float("inf")
#MOD=10**9+7
# sys.setrecursionlimit(2147483647)
# import math
#import numpy as np
# import operator
# import bisect
# from heapq import heapify,heappop,heappush
#from math import gcd
# from fractions import gcd
# from collections import deque
# from collections import defaultdict
# from collections import Counter
# from itertools import accumulate
# from itertools import groupby
# from itertools import permutations
# from itertools import combinations
# from scipy.sparse import csr_matrix
# from scipy.sparse.csgraph import floyd_warshall
# from scipy.sparse.csgraph import csgraph_from_dense
# from scipy.sparse.csgraph import dijkstra
# map(int,input().split())


def main():
	n=int(input())
	A=list(map(int,input().split()))
	ans=[0]*(n+1)
	
	for i in range(n,0,-1):
		ans[i]=(sum(ans[::i])%2) ^ A[i-1]
	
	print(sum(ans))
	print(*[i for i,x in enumerate(ans) if x==1])
	
	
if __name__ == '__main__':
	main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
a=list(map(int,input().split()))
b=[0 for i in range(n)]
res=0
for i in range(n-1,-1,-1):
    cnt=0
    for j in range(i,n,i+1): #j+1の倍数
        cnt+=b[j]
    if cnt%2!=a[i]:
        b[i]+=1
        res+=1

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

Submission status: Accepted

Solution code:
#ABC134 D - Preparing Boxes
N = int(input())
A = [0]+list(map(int,input().split()))
B = []
T = [0]*(N+1)

for i in range(N,0,-1):
    total = 0
    v = i
    while v <= N:
        total += T[v]
        v += i
    if total%2 != A[i]:
        T[i]=1
        B.append(i)

B.sort()
if len(B)>0:
    print(len(B))
    print(*B)
else:
    print(0)

Submission status: Accepted

Solution code:
# 約数列挙
def make_divisors(value):
    divisors = []
    # int(n ** 0.5) は valueの平方根（小数点以下切り捨て）
    for i in range(1, int(value ** 0.5) + 1):
        if value % i == 0:
            divisors.append(i)              # 約数の下半分を追加
            if i != value // i:             # iが中央値なら下記を飛ばす
                divisors.append(value//i)   # 約数の上半分を追加
    # ソートする場合は下記コメントをはずす
    # divisors.sort()
    return divisors
 
N = int(input())
a = list(map(int, input().split()))
memo = [0] * N
anser = []
for i in range(N - 1, -1, -1):
    if (a[i] == 1 and memo[i] == 0) or (a[i] == 0 and memo[i] == 1):
        anser.append(i + 1)
        # iの約数を抽出
        divisors = make_divisors(i + 1)
        for j in divisors:
            memo[j - 1] = (memo[j - 1] + 1) % 2
 
print(len(anser))
if len(anser) >=  1:
    print(" ".join(map(str, anser)))

Submission status: Accepted

Solution code:
import os

input = os.sys.stdin.readline

N = int(input())

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

ans = False
b = [0]*N

for i in range(N, 0 ,-1):
    b_sum = 0
    for j in range(i, N+1, i):
        b_sum += b[j-1]
    if b_sum % 2 != a[i-1]: b[i-1] = 1
if b==[0]*N:print(0)      
else:
    print(sum(b))
    print(*[k+1 for k, l in enumerate(b) if l==1])

Submission status: Accepted

Solution code:
N = int(input())

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

ans = False
b = [0]*N


for i in range(N, 0 ,-1):
    b_sum = 0
    for j in range(i, N+1, i):
        b_sum += b[j-1]
    if b_sum % 2 != a[i-1]: b[i-1] = 1
if b==[0]*N:print(0)      
else:
    print(sum(b))
    print(*[k+1 for k, l in enumerate(b) if l==1])

Submission status: Accepted

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


def main():
    N = int(input())
    a = list(map(int, input().strip().split()))
    ans = [0] * N

    for i, a_r in enumerate(a[::-1]):
        j = N - i - 1
        count = 0
        now = j+1
        while now <= N:
            count += ans[now-1]
            now += j+1

        if a_r == 0:
            if count % 2 == 1:
                ans[j] = 1
        else:
            if count % 2 == 0:
                ans[j] = 1

    output = ""
    count = 0
    for i, b in enumerate(ans):
        if b == 1:
            output += str(i+1) + " "
            count += 1
    print(count)
    if count != 0:
        print(output[:-1])


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
def solve():
    N, *a_l = map(int, open(0).read().split())
    a_l = [0] + a_l

    for i in range(N//2, 0, -1):
        a_l[i] = sum(a_l[i::i]) % 2

    b_l = [i for i, x in enumerate(a_l) if x]

    print(len(b_l))
    if len(b_l) != 0:
        print(' '.join(map(str, b_l)))


if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
class Solver():
  def __init__(self):
    self._N = int(input())
    self._data = list(map(int, input().split()))
    self._ans  = [0 for i in range(self._N)]
  
  def print_member(self):
    print("N = {}".format(self._N))
    for i in self._data:
      print(i, end=" ")
      
  
  def solve(self):
    flag = True
    for i in reversed(range(1,self._N+1)):
      i_mul   = i
      sum_mul = 0
      while(i_mul<self._N+1):
        sum_mul += self._ans[i_mul-1]
        i_mul   += i
      if(sum_mul%2 != self._data[i-1]):
        self._ans[i-1] += 1
        self._ans[i-1] %= 2
             
    if(flag):
      print(sum(self._ans))
      for i in range(self._N):
        if(self._ans[i]):
          print(i+1, end=" ")
          
if __name__ == '__main__':
  solver = Solver()
  solver.solve()

Submission status: Accepted

Solution code:
n = int(input())
a = list(map(int, input().split( )))
ans = [0]*n
for i in range(n,0,-1):
    tmp = a[i-1]
    for j in range(n//i,1,-1):##上から、下限2?
        tmp+=ans[i*j-1]
    ans[i-1] = tmp%2

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

Submission status: Accepted

Solution code:
def main():
    n=int(input())
    a = list(map(int,input().split()))
    if a==[0 for _ in range(n)]:
        print(0)
        return
    box=[0 for _ in range(n)]
    for i in range(n,0,-1):
        if n//i==1:
            box[i-1]=a[i-1]
        else:
            c=0
            for j in range((n//i)-1):
                c+=box[(j+2)*i-1]
            box[i-1]=(a[i-1]+c)%2
    print(sum(box))
    ans=[]
    for i in range(n):
        if box[i]==1:
            ans.append(str(i+1))
    print(' '.join(ans))

if __name__ == "__main__":
    main()