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
import copy

#任意の数の倍数リストを作成する
def make_multiple(N,target):
	multiple_list = list()
	for i in range(1,N+1): #この書き方って0も入るじゃない??
		if i % target == 0:
			multiple_list.append(i)
	return multiple_list



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

#全て0の時はそのまま0を表示して終了
a_c = copy.deepcopy(a)
a_s =set(a_c)
a_c = list(a_s)
if len(a_c) == 1 and a_c[0] == 0:
	print(0)
	sys.exit()

a.insert(0,0) #便宜上一番最初に0をinsert、最後にpopする

for i in range(len(a)):
	target_list = list()
	if a[i] != 0:
		# print('a[',i,']:',a[i])
		target_list =make_multiple(N,a[i])
		# if len(target_list) 
		# print(target_list,':',len(target_list))
		# print(len(target_list),'%',2,'=',len(target_list)%2)
		print(1)
		print(target_list[0])

Submission status: Wrong Answer

Solution code:
N = int(input())
a = [int(i) for i in input().split()]
b = [0]*N
M = 0
for i in range(N-1,N//2-1,-1):
  if a[i] == 1:
    M += 1
    b[i] = 1
  
for i in range(N//2-1,-1,-1):
  j = (i+1)*2
  tmp = 0
  while j <= N:
    tmp += b[j-1]
    j += i+1
  if tmp%2 != a[i]:
    b[i] = 1
    M += 1
print(M)
print(" ".join(map(str,b)))

Submission status: Wrong Answer

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

b = []
for n in range(N,0,-1):
  #print('  a[{}]={}'.format(n,a[n-1]))
  total = a[n-1]
  for i in range(n+n,N,n):
    total += a[i-1]
  if total!=0:
    b.append(n)

print(len(b))
for bm in b:
  print('{} '.format(bm))

Submission status: Wrong Answer

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

b = []
for n in range(N,0,-1):
  #print('  a[{}]={}'.format(n,a[n-1]))
  total = a[n-1]
  for i in range(n+n,N,n):
    total += a[i-1]
  if total!=0:
    a[n-1] = 0
    b.append(n)

print(len(b))
for bm in b:
  print('{} '.format(bm))

Submission status: Wrong Answer

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

#link = [[] for _ in range(15)]
linkinv = [[] for _ in range(200005)]
for n in range(1,N):
  for i in range(n,N,n):
    #link[n].append(i)
    linkinv[i].append(n)
#print(link)
#print(linkinv)

b = []
for n in range(N,0,-1):
  #print('  a[{}]={}'.format(n,a[n-1]))
  if a[n-1]==0:
    continue
  b.append(n)
  for k in linkinv[n]:
    a[k-1] = (a[k-1]+1)%2

print(len(b))
for bm in b:
  print('{} '.format(bm))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
ls = [0] * n
ans = []
for i in range(n-1, -1, -1):
    t = 0
    for j in range(i, n, (i + 1)):
        t += ls[j]
    if a[i] % 2 != t % 2:
        ans.append(1)
        ls[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()))
ls = [0] * n
ans = []
for i in range(n-1, -1, -1):
    t = 0
    for j in range(i, n, (i + 1)):
        t += ls[j]
    if a[i] % 2 != t % 2:
        ans.append(1)
        ls[j] = 1
print(len(ans))
if len(ans) != 0:
    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 reversed(range(1, n+1)):
    if 2 * i > n:
        bi = a[i]
    else:
        bi = 0
        for j in range(2, n//i + 1):
            bi += b[i*j]
        bi %= 2

        if bi != a[i]:
            bi = 1
        else:
            bi = 0

    # print(i, bi)
    b[i] = bi

m = sum(b)
print(m)
if m > 0:
    b_idx = [str(i) for i in range(n) if b[i] == 1]
    print(' '.join(b_idx))

Submission status: Wrong Answer

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

m = 0
b = []
for i in reversed(range(1, n+1)):
    if 2 * i > n:
        bi = a[i]
    else:
        bi = 0
        for j in range(1, n//i + 1):
            bi += a[i*j]
        bi %= 2

        if bi != a[i]:
            m = -1
            break

    if bi == 1:
        b.append(i)

b = list(reversed(b))
if m == -1:
    print(m)
else:
    print(len(b))
    if len(b) > 0:
        print(' '.join([str(bi) for bi in b]))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [int(i) for i in input().split()]
b = [0] * n
ans = []
for i in range(n)[::-1]:
    tmp = i+1
    pl = a[i]
    tmp += tmp
    while tmp <= n:
        pl += b[tmp-1]
        tmp += tmp
    b[i] = pl % 2
for i in range(n):
    if b[i] == 1:
        ans.append(i+1)
print(len(ans))
print(*ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
An = input().split(' ')
ball_list = [0 for _ in range(N)]
output_list = []
count = 0
for i in range(N):
    detect_num = int(N / (N - i))
    sum_amari = 0
    for s in range(detect_num):
        sum_amari += ball_list[ (N - i -1) * (s+1) ]
    if sum_amari % 2 != int(An[N - i -1]): 
        ball_list[N - i -1] = 1
        output_list.insert(0,str(N - i))
        count += 1


print(count)
if count > 0:
    print(' '.join(output_list))

Submission status: Wrong Answer

Solution code:
N = int(input())
An = input().split(' ')
ball_list = [0 for _ in range(N)]

for i in range(N):
    detect_num = int(N / (N - i))
    sum_amari = 0
    for s in range(detect_num):
        sum_amari += ball_list[ (N - i -1) * (s+1) ]
    if sum_amari % 2 != int(An[N - i -1]): 
        ball_list[N - i -1] = 1

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

Submission status: Wrong Answer

Solution code:
n=int(input())
A=list(map(int,input().split()))
from collections import defaultdict

balls = defaultdict(int)
for i in range(n-1,-1,-1):
    count=A[i]
    for j in range(n//(i+1)):
        count+=balls[(j*(i+1))-1]
    if count%2:
        balls[i]=1

ans=[i+1 for i in range(n) if balls[i]==1]
print(len(ans))
print(*ans)

Submission status: Wrong Answer

Solution code:
#43 ABC134D
n=int(input())
a=list(map(int,input().split()))
x=[0 for _ in range(n)]
for i in range(n,0,-1):
	x[i-1]=sum([a[j] for j in range(i-1,n,i)])%2
j=True
for i in range(n):
	if a[i]!=sum([a[j] for j in range(i,n,i+1)])%2:
		j=False
if j:
	print(sum(x))
	if sum(x)!=0:
		res=[]
		for i,t in enumerate(x):
			if t==1:
				res.append(str(i+1))
		print(" ".join(res))
else:
	print(-1)

Submission status: Wrong Answer

Solution code:
#43 ABC134D
n=int(input())
a=list(map(int,input().split()))
x=[0 for _ in range(n)]
for i in range(n,0,-1):
	x[i-1]=sum([a[j] for j in range(i-1,n,i)])%2
print(sum(x))
if sum(x)!=0:
	res=[]
	for i,t in enumerate(x):
		if t==1:
			res.append(str(i+1))
	print(" ".join(res))

Submission status: Wrong Answer

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

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

ans = []
for i in list(range(N, 0, -1)):
    sum = 0
    for j in list(range(2 * i, N, i)):
        sum ^= B[j]
    B[i] = sum ^ A[i]
    if B[i]:
        ans.append(str(i))

print(len(ans))
if ans:
    print(' '.join(ans))

Submission status: Wrong Answer

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

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

ans = []
for i in range(N, 0, -1):
    sum = 0
    for j in range(2 * i, N, i):
        sum ^= B[j]
    B[i] = sum ^ A[i]
    if B[i]:
        ans.append(str(i))
        
print(len(ans))
if ans:
    print(' '.join(ans))

Submission status: Wrong Answer

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

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

for i in range(N, 0, -1):
    sum = 0
    for j in range(2 * i, N, i):
        sum ^= B[j]
    B[i] = sum ^ A[i]
ans = []
for i in range(1, N+1):
    if B[i]:
        ans.append(str(i))
print(len(ans))
if ans:
    print(' '.join(ans))

Submission status: Wrong Answer

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

N = int(input())
A = [0] + list(map(int, input().split()))
B = [0 for _ in range(N+1)]

for i in range(N, 0, -1):
    sum = 0
    for j in range(2 * i, N, i):
        sum ^= B[j]
    B[i] = sum ^ A[i]
ans = []
for i in range(1, N+1):
    if B[i]:
        ans.append(str(i))
print(len(ans))
if ans:
    print(' '.join(ans))

Submission status: Wrong Answer

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

for i in range(N, 0, -1):
    sum = 0
    for j in range(2*i, N, i):
        sum ^= B[j]
    B[i] = sum ^ A[i]
ans = []
for i in range(1, N+1):
    if B[i]:
        ans.append(str(i))
print(len(ans))
if ans:
    print(' '.join(ans))

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split())) + ['']
inv_A = A[::-1]
B = [0 for i in range(N+1)]

for i in range(1, N+1):
    sum = 0
    for j in range(2*i, N, i):
        sum ^= B[j]
    B[N-i+1] = sum ^ inv_A[i]
ans = []
for i in range(1, N+1):
    if B[i]:
        ans.append(str(i))
print(len(ans))
if ans:
    print(' '.join(ans))

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
inv_A = A[::-1]
B = [0 for i in range(N+1)]
ball_cnt = 0
for i in range(N):
    sum = 0
    cnt = 2
    while True:
        if cnt * (i+1) > N:
            break
        sum += B[cnt * (i+1)]
        cnt += 1
    if sum % 2 == inv_A[i]:
        B[N-i] = 0
    else:
        B[N-i] = 1
        ball_cnt += 1
if ball_cnt:
    print(ball_cnt)
    for i in range(1, N+1):
        if B[i]:
            print(i, end=' ')
else:
    print(0)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
inv_A = A[::-1]
B = [0 for i in range(N+1)]
ball_cnt = 0
for i in range(N):
    sum = 0
    cnt = 2
    while True:
        if cnt * (i+1) > N:
            break
        sum += B[cnt * (i+1)]
        cnt += 1
    if sum % 2 == inv_A[i]:
        B[N-i] = 0
    else:
        B[N-i] = 1
        ball_cnt += 1
if ball_cnt:
    print(ball_cnt)
    cnt = 0
    for i in range(N+1):
        if cnt == ball_cnt:
            break
        if B[i+1] == 1:
            print(1, end=' ')
            cnt += 1
        else:
            print(0, end=' ')
else:
    print(0)

Submission status: Wrong Answer

Solution code:
from collections import deque

n = int(input())
A = list(map(int, input().split()))
ans = deque([])
num = deque([])

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

    # divisors.sort()
    return divisors


for i in range(n-1, -1, -1):
    if A[i] == 0:
        continue
    else:
        ans.appendleft(i+1)
        for j in make_divisors(i+1):
            A[j-1] = not A[j-1]

print(len(ans))
for i in ans:
    print(i)

Submission status: Wrong Answer

Solution code:
from collections import deque

n = int(input())
A = list(map(int, input().split()))
ans = deque([])
num = deque([])

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

    # divisors.sort()
    return divisors


for i in range(n-1, -1, -1):
    if A[i] == 0:
        ans.appendleft(0)
    else:
        ans.appendleft(1)
        num.appendleft(i+1)
        for j in make_divisors(i+1):
            A[j-1] = ~A[j-1]

print(sum(ans))
for q in num:
    print(q)

Submission status: Wrong Answer

Solution code:
def main(a):
    for ind,_ in enumerate(a):
        #print(inds[ind::ind+1])
        buf = a[ind::ind+1]
        if (buf[0]==0 and sum(buf)%2==0) or (buf[0]==1 and sum(buf)%2==1):
            pass
        else:
            print(-1)
            return

    print(sum(a))
    for ind,x in enumerate(a):
        if x == 1:print(ind+1)
          
N = int(input())
a = [int(x) for x in input().split()]
    
main(a)

Submission status: Wrong Answer

Solution code:
def main(a):
    for ind,_ in enumerate(a):
        #print(inds[ind::ind+1])
        buf = a[ind::ind+1]
        if (buf[0]==0 and sum(buf)%2==0) or (buf[0]==1 and sum(buf)%2==1):
            pass
        else:
            print(-1)
            return

    print(sum(a))
    if sum(a)>0:print(' '.join([str(ind+1) for ind,x in enumerate(a) if x == 1]))

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

Submission status: Wrong Answer

Solution code:
def main(a):
    for ind,_ in enumerate(a):
        #print(inds[ind::ind+1])
        buf = a[ind::ind+1]
        if (buf[0]==0 and sum(buf)%2==0) or (buf[0]==1 and sum(buf)%2==1):
            pass
        else:
            print(-1)
            return 0

    print(sum(a))
    if sum(a)>0:print(' '.join([str(ind+1) for ind,x in enumerate(a) if x == 1]))

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

Submission status: Wrong Answer

Solution code:
def main(a):
    for ind,_ in enumerate(a):
        #print(inds[ind::ind+1])
        buf = a[ind::ind+1]
        if (buf[0]==0 and sum(buf)%2==0) or (buf[0]==1 and sum(buf)%2==1):
            pass
        else:
            print(-1)
            return 0

    print(sum(a))
    print(' '.join([str(ind+1) for ind,x in enumerate(a) if x == 1]))

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

Submission status: Wrong Answer

Solution code:
# define parameters
N = int(input())
a = [int(i) for i in input().split()]
dicts = {}
total_balls = 0
for i in range(N):
  dicts[i+1] = 0
  
# main
for i in range(N, 0, -1):
  balls = 0
  for j in range(1, N):
    try:
      balls += dicts[i*j]
    except KeyError:
      break
if balls % 2 != a[i-1]:
  dicts[i] = 1
  total_balls += 1
  
# output
print(total_balls)
if total_balls > 0:
  for k,v in dicts.items():
    if v == 1:
      print(k, end = " ")

Submission status: Wrong Answer

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

"""考え方
まず、必ずうまくいくやり方が存在する。
その上で、iが奇数か偶数か、aiが0,1のいずれなのか、といったところからMやボールを入れた箱のインデックスを求めていくだけ
"""

M = 0
str_ball_in = ''

"""
for i,a in enumerate(A, start=1):
  print(i)
  ## 箱のインデックスが偶数
  if i % 2 == 0:
    print('even')
    if a == 1:
      M += 1
      list_ball_in.append(i)
  ## 箱のインデックスが奇数
  else:
    print('odd')
    if a == 1:
      M += 1
      list_ball_in.append(i)
"""

for i,a in enumerate(A, start=1):
  if a == 1:
    M += 1
    str_ball_in = str_ball_in + ' ' + str(i)
      
print(M)
print(str_ball_in[1:])

Submission status: Wrong Answer

Solution code:
import glob
import numpy as np


# 問題ごとのディレクトリのトップからの相対パス
REL_PATH = 'ABC\\134\\D'

# テスト用ファイル置き場のトップ
TOP_PATH = 'C:\\AtCoder'

class Common:

    problem = []
    index = 0

    def __init__(self, rel_path):
        self.rel_path = rel_path

    def initialize(self, path):
        file = open(path)
        self.problem = file.readlines()
        self.index = 0
        return

    def input_data(self):
        try:
            IS_TEST
            self.index += 1
            return self.problem[self.index-1]

        except NameError:
            return input()

    def resolve(self):
        pass

    def exec_resolve(self):
        try:
            IS_TEST
            for path in glob.glob(TOP_PATH + '\\' + self.rel_path + '/*.txt'):
                print("Test: " + path)
                self.initialize(path)
                self.resolve()
                print("\n\n")
        except NameError:
            self.resolve()


class D(Common):

    def resolve(self):

        box_num = int(self.input_data())
        remain = [int(i) for i in self.input_data().split()]

        boxes = np.zeros(box_num, dtype=np.int)
        for box in range(box_num, 0, -1):
            sum = np.max(boxes[box-1::box])
            if sum % 2 != remain[box-1]:
                boxes[box-1] = 1

        print(str(np.sum(boxes)))
        for i in range(box_num):
            if boxes[i] == 1:
                print(str(i+1), end=" ")


solver = D(REL_PATH)
solver.exec_resolve()

Submission status: Wrong Answer

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


def get_divisors(n, reverse=False):
    from math import sqrt
    divisors = []
    for num in range(1, int(sqrt(n))+1):
        if n % num == 0:
            divisors.append(num)
            if n//num != num:
                divisors.append(n//num)
    return sorted(divisors, reverse=reverse)

status = [0] * N
answers = []
for i in range(N, 0, -1):
    if A[i-1] == status[i-1]:
        continue
    answers.append(i)
    divisors = get_divisors(i)
    a = A[i-1]
    for divisor in divisors:
        status[divisor-1] = (a + status[divisor-1]) % 2

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

Submission status: Wrong Answer

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


def get_divisors(n, reverse=False):
    from math import sqrt
    divisors = []
    for num in range(1, int(sqrt(n))+1):
        if n % num == 0:
            divisors.append(num)
            if n//num != num:
                divisors.append(n//num)
    return sorted(divisors, reverse=reverse)

status = [0] * N
answers = []
for i in range(N, 0, -1):
    if A[i-1] == status[i-1]:
        continue
    answers.append(i)
    divisors = get_divisors(i)
    a = A[i-1]
    for divisor in divisors:
        status[divisor-1] = a

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

Submission status: Wrong Answer

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


def get_divisors(n, reverse=False):
    from math import sqrt
    divisors = []
    for num in range(1, int(sqrt(n))+1):
        if n % num == 0:
            divisors.append(num)
            if n//num != num:
                divisors.append(n//num)
    return sorted(divisors, reverse=reverse)

status = [0] * N
answers = []
for i in range(N, 0, -1):
    if A[i-1] == status[i-1]:
        continue
    answers.append(i)
    divisors = get_divisors(i)
    for divisor in divisors:
        status[divisor-1] = A[i-1]

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

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
B = [0 for i in range(N)]
for n in range(N):
    step = N - n
    sm = A[step-1]
    for i in range(step-1, N ,step)[::-1]:
        sm += B[i]
    B[step-1] = (sm%2)
    print (B)
#print (sum(B))
C = " ".join([str(i+1) for i in range(len(B)) if B[i]])
print (C)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
B = [0 for i in range(N)]
for n in range(N):
    step = N - n
    sm = A[step-1]
    for i in range(step-1, N ,step)[::-1]:
        sm += B[i]
    B[step-1] = (sm%2)
    print (B)
print (sum(B))
C = " ".join([str(i+1) for i in range(len(B)) if B[i]])
print (C)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
B = [0 for i in range(N)]
for n in range(N):
    step = N - n
    sm = A[step-1]
    for i in range(step-1, N ,step)[::-1]:
        sm += B[i]
    B[step-1] = (sm%2)
print (sum(B))
C = " ".join([str(b) for b in B if b])
print (C)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
B = [0 for i in range(N)]
for n in range(N):
    step = N - n
    i = step - 1
    sm = 0
    j = i
    while(j<N):
        sm += B[j]
        j+=step
    B[i] = (sm+A[i])%2
print (sum(B))
C = " ".join([str(b) for b in B if b])
print (C)

Submission status: Wrong Answer

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

r=[0]*n

for i in range(n)[::-1]:
    if sum(r[i::i+1]) != a[i]:
        r[i]=1

print(sum(r))
for index, i in enumerate(r):
    if i == 1:
        print(index+1)

Submission status: Wrong Answer

Solution code:
#coding utf-8
N=int(input())
a=list(map(int,input().split())) 
a=[0]+a
b=[0 for i in range(N+1)]
for i in range(N,0,-1):
  y=2
  tmp=0
  x=i*y
  while x<N+1:
    tmp+=a[x]
    y +=1
    x=i*y
  if tmp%2!=a[i]:
    b[i]=1
    
print(b.count(1))
indexes = [i for i,x in enumerate(b) if x==1]
indexes = map(str,indexes)
if b.count(1)!=0:
  print(' '.join(indexes))

Submission status: Wrong Answer

Solution code:
#coding utf-8
N=int(input())
a=list(map(int,input().split())) 
a=[0]+a
b=[0 for i in range(N+1)]
for i in range(N,0,-1):
  y=2
  tmp=0
  x=i*y
  while x<N+1:
    tmp+=a[x]
    y +=1
    x=i*y
  if tmp%2!=a[i]:
    b[i]=1
    
print(b.count(1))
indexes = [i for i,x in enumerate(b) if x==1]
indexes = map(str,indexes)
print(' '.join(indexes))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#######################################
import numpy as np
#######################################
n = int(input())
a = np.array(list(map(int, input().split())))
ret = np.zeros(n+1, dtype="int")
tmp = list(range(n+1))
ret2 = []

for i in reversed(list(range(n))): 
  if sum(ret[::i+1][1:])%2 != a[i]:
    ret[i+1] = 1
    ret2.append(i)

print(sum(ret[1:]))
ret2 = list(map(str, ret2))
print(" ".join(ret2))

Submission status: Wrong Answer

Solution code:
#######################################
import numpy as np
import math
import copy
import re
import sys
#sys.exit(0)

inf = float("inf")
prime = 1

def check_print(check_flag, text, end="\n"):
  if check_flag:
    print(text, end=end)

def c2i(x):
    if str.isdecimal(x):
        return int(x)
    else:
        return x

def cout(*args):
  arglist = []
  for arg in args:
    if hasattr(arg, "__iter__"):
      arglist.extend(arg)
    else:
      arglist.append(arg)
      
  arglist = list(map(str, arglist))
  print(" ".join(arglist))
  
def count2(num):
  count=0
  while num%2==0:
    num/=2
    count+=1
  return count

def ketasum(num):
  nums = [int(s) for s in str(num)]
  return sum(nums)

#math
def gcd(a, b): #最大公約数
  while b:
    a, b = b, a % b
  return a

def lcm(a, b): #最小公倍数
  return a * b // gcd (a, b)

def gcd3(lis): #最大公約数(3over)
  ans = lis[0]
  for li in lis:
    ans = gcd(ans,li)

def lcm3(lis): #最小公倍数(3over)
  ans = lis[0]
  for li in lis:
    ans = lcm(ans,li)

def divisor(n): #nの約数を全て求める
  i = 1
  table = []
  while i * i <= n:
    if n%i == 0:
      table.append(i)
      table.append(n//i)
    i += 1
  table = list(set(table))
  return table

def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n /= i
      table.append(i)
    i += 1
  if n > 1:
    table.append(n)
  return table

def is_prime(n):
  for i in range(2, n + 1):
    if i * i > n:
      break
    if n % i == 0:
      return False
  return n != 1

#input stock
"""
n = int(input())

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

#縦1dim-list
a = [int(input()) for i in range(n)]

d=[]
for i in range(n):
  d[i]=int(input())

#2dim-list
a = [list(map(int, input().split())) for i in range(n)]

s = input()
ss =  [int(si) for si in s]
"""

#processing stock
"""
a = sorted(a)
a = sorted(a, reverse=True)

"""

#regex
"""
pattern = ""
result = re.search(pattern, s)

result = re.fullmatch(pattern, s)

result = re.finditer(pattern, s)
for res in result:
    print res.group()   # 1回目: ca      2回目: ca   
    print res.start()   # 1回目: 0       2回目: 6      
    print res.end()     # 1回目: 2       2回目: 8      
    print res.span()    # 1回目: (0, 2)  2回目: (6, 8)
"""


#math
"""
#切り捨て
math.floor()
# 切り上げ
math.ceil()
"""

#######################################
n = int(input())
a = np.array(list(map(int, input().split())))
ret = np.zeros(n+1, dtype="int")
#tmp = list(range(n+1))

for i in reversed(list(range(n))):
  #print(tmp[::i+1][1:])
  if sum(ret[::i+1][1:])%2 != a[i]:
    ret[i+1] = 1

cout(ret[1:])

Submission status: Wrong Answer

Solution code:
#######################################
import numpy as np
import math
import copy
import re
import sys
#sys.exit(0)

inf = float("inf")
prime = 1

def check_print(check_flag, text, end="\n"):
  if check_flag:
    print(text, end=end)

def c2i(x):
    if str.isdecimal(x):
        return int(x)
    else:
        return x

def cout(*args):
  arglist = []
  for arg in args:
    if hasattr(arg, "__iter__"):
      arglist.extend(arg)
    else:
      arglist.append(arg)
      
  arglist = list(map(str, arglist))
  print(" ".join(arglist))
  
def count2(num):
  count=0
  while num%2==0:
    num/=2
    count+=1
  return count

def ketasum(num):
  nums = [int(s) for s in str(num)]
  return sum(nums)

#math
def gcd(a, b): #最大公約数
  while b:
    a, b = b, a % b
  return a

def lcm(a, b): #最小公倍数
  return a * b // gcd (a, b)

def gcd3(lis): #最大公約数(3over)
  ans = lis[0]
  for li in lis:
    ans = gcd(ans,li)

def lcm3(lis): #最小公倍数(3over)
  ans = lis[0]
  for li in lis:
    ans = lcm(ans,li)

def divisor(n): #nの約数を全て求める
  i = 1
  table = []
  while i * i <= n:
    if n%i == 0:
      table.append(i)
      table.append(n//i)
    i += 1
  table = list(set(table))
  return table

def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n /= i
      table.append(i)
    i += 1
  if n > 1:
    table.append(n)
  return table

def is_prime(n):
  for i in range(2, n + 1):
    if i * i > n:
      break
    if n % i == 0:
      return False
  return n != 1

#input stock
"""
n = int(input())

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

#縦1dim-list
a = [int(input()) for i in range(n)]

d=[]
for i in range(n):
  d[i]=int(input())

#2dim-list
a = [list(map(int, input().split())) for i in range(n)]

s = input()
ss =  [int(si) for si in s]
"""

#processing stock
"""
a = sorted(a)
a = sorted(a, reverse=True)

"""

#regex
"""
pattern = ""
result = re.search(pattern, s)

result = re.fullmatch(pattern, s)

result = re.finditer(pattern, s)
for res in result:
    print res.group()   # 1回目: ca      2回目: ca   
    print res.start()   # 1回目: 0       2回目: 6      
    print res.end()     # 1回目: 2       2回目: 8      
    print res.span()    # 1回目: (0, 2)  2回目: (6, 8)
"""


#math
"""
#切り捨て
math.floor()
# 切り上げ
math.ceil()
"""

#######################################
n = int(input())
a = np.array(list(map(int, input().split())))
ret = np.zeros(n+1, dtype="int")
tmp = list(range(n+1))

for i in reversed(list(range(n))):
  print(tmp[::i+1][1:])
  if sum(ret[::i+1][1:])%2 != a[i]:
    ret[i+1] = 1

cout(ret[1:])

Submission status: Wrong Answer

Solution code:
#######################################
import numpy as np
import math
import copy
import re
import sys
#sys.exit(0)

inf = float("inf")
prime = 1

def check_print(check_flag, text, end="\n"):
  if check_flag:
    print(text, end=end)

def c2i(x):
    if str.isdecimal(x):
        return int(x)
    else:
        return x

def cout(*args):
  arglist = []
  for arg in args:
    if hasattr(arg, "__iter__"):
      arglist.extend(arg)
    else:
      arglist.append(arg)
      
  arglist = list(map(str, arglist))
  print(" ".join(arglist))
  
def count2(num):
  count=0
  while num%2==0:
    num/=2
    count+=1
  return count

def ketasum(num):
  nums = [int(s) for s in str(num)]
  return sum(nums)

#math
def gcd(a, b): #最大公約数
  while b:
    a, b = b, a % b
  return a

def lcm(a, b): #最小公倍数
  return a * b // gcd (a, b)

def gcd3(lis): #最大公約数(3over)
  ans = lis[0]
  for li in lis:
    ans = gcd(ans,li)

def lcm3(lis): #最小公倍数(3over)
  ans = lis[0]
  for li in lis:
    ans = lcm(ans,li)

def divisor(n): #nの約数を全て求める
  i = 1
  table = []
  while i * i <= n:
    if n%i == 0:
      table.append(i)
      table.append(n//i)
    i += 1
  table = list(set(table))
  return table

def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n /= i
      table.append(i)
    i += 1
  if n > 1:
    table.append(n)
  return table

def is_prime(n):
  for i in range(2, n + 1):
    if i * i > n:
      break
    if n % i == 0:
      return False
  return n != 1

#input stock
"""
n = int(input())

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

#縦1dim-list
a = [int(input()) for i in range(n)]

d=[]
for i in range(n):
  d[i]=int(input())

#2dim-list
a = [list(map(int, input().split())) for i in range(n)]

s = input()
ss =  [int(si) for si in s]
"""

#processing stock
"""
a = sorted(a)
a = sorted(a, reverse=True)

"""

#regex
"""
pattern = ""
result = re.search(pattern, s)

result = re.fullmatch(pattern, s)

result = re.finditer(pattern, s)
for res in result:
    print res.group()   # 1回目: ca      2回目: ca   
    print res.start()   # 1回目: 0       2回目: 6      
    print res.end()     # 1回目: 2       2回目: 8      
    print res.span()    # 1回目: (0, 2)  2回目: (6, 8)
"""


#math
"""
#切り捨て
math.floor()
# 切り上げ
math.ceil()
"""

#######################################
n = int(input())
a = np.array(list(map(int, input().split())))
ret = np.zeros(n+1, dtype="int")
#tmp = list(range(n+1))

for i in reversed(list(range(n))):
  #print(tmp[::i+1][1:])
  if sum(ret[::i+1][1:])%2 != a[i]:
    ret[i+1] = 1

cout(ret)