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 math

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

for i in reversed(range(N)):
        x = math.ceil(N/(i+1))
        temp = 0
        for k in range(x):
            temp = temp + b[k*(i+1) - 1]
        if a[i] != (temp%2):
            b[i] = 1
M = b.count(1)
print(M)
if M != 0:
    for i in range(N):
        if b[i] ==1:
            print(str(i+1) + " ", end = "")

Submission status: Wrong Answer

Solution code:
import math

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

for i in reversed(range(N)):
        x = math.ceil(N/(i+1))
        temp = 0
        for k in range(x):
            temp = temp + b[k*(i+1) - 1]
        if a[i] != (temp%2):
            b[i] = 1
M = b.count(1)
print(M)
if M != 0:
    for i in range(N):
        if b[i] ==1:
            print(str(i+1) + " ")

Submission status: Wrong Answer

Solution code:
import math

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

for i in reversed(range(N)):
        x = math.ceil(N/(i+1))
        temp = 0
        for k in range(1,x):
            temp = temp + b[k*(i+1)]
        if a[i] != (temp%2):
            b[i] = 1
M = b.count(1)
print(M)
if M != 0:
    for i in range(N):
        if b[i] ==1:
            print(str(i+1) + " ")

Submission status: Wrong Answer

Solution code:
import math

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

for i in reversed(range(N)):
        x = math.ceil(N/(i+1))
        temp = 0
        for k in range(1,x):
            temp = temp + b[k*i-1]
        if a[i] != (temp%2):
            b[i] = 1
M = b.count(1)
print(M)
if M != 0:
    for i in range(N):
        if b[i] ==1:
            print(str(i+1) + " ")

Submission status: Wrong Answer

Solution code:
import math

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

for i in reversed(range(N)):
        x = math.ceil(N/(i+1))
        temp = 0
        for k in range(x):
            temp = temp + b[k*(i+1)-1]
        if a[i] != (temp%2):
            b[i] = 1
M = b.count(1)
print(M)
if M != 0:
    for i in range(N):
        if b[i] ==1:
            print(str(i+1) + " ")

Submission status: Wrong Answer

Solution code:
n=int(input())
a=[int(x) for x in input().split()]

t=0
for i in range(1,n):
  t += a[i]

if a[0]^(t%2):
  print(t+1)
  print(1)
else:
  print(t)

for i in range(1,n):
  if a[i]==1:
    print(i)

Submission status: Wrong Answer

Solution code:
#coding : utf-8

import os
import sys

N = int(input())

a = list(map(lambda x: int(x), input().split(" ")))

#print(N)
#print(a)

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

#print(box)

for i in range(N, 0, -1):
	#print(f"i={i}, a{i}={a[i-1]}")

	idx = []
	for k in range(1, N+1):
		v = i * k
		if v > N:
			break
		idx.append(v)

	idx.reverse()

	#print(idx)

	balls = 0
	for k in idx:
		balls += box[k-1]
	
	#print(balls)

	if a[i-1] == 0:
		if balls == 0:
			box[i-1] = 0
		else:
			box[i-1] = 1
	else:
		if balls == 0:
			box[i-1] = 1
		else:
			box[i-1] = 0

#print(box)

print(box.count(1))

first = True

for i, b in enumerate(box):
	if b == 1:
		if first:
			first = False
		else:
			print(" ", end="")
		print("%d" % (i+1), end="")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def calc(n):
    k = int((n ** (0.5)) // 1) + 1
    s = []
    for i in range(1, k):
        if n % i == 0:
            s.append(i)
            s.append(int(n // i))
    s = list(set(sorted(s)))
    return sorted(s)


n = int(input())
a = [int(i) for i in input().split()]
b = [0] * n
k = []
for i in range(n-1, -1, -1):
    if a[i] == 1:
        kk = calc(i+1)
        for kkk in kk:
            b[kkk-1] += a[i]
            b[kkk-1] = b[kkk-1] % 2
    if b[i] == 1:
        k.append(i+1)
if a == b:
    print(len(k))
    for jjj in k:
        print(jjj)
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
def calc(n):
    k = int((n ** (0.5)) // 1) + 1
    s = []
    for i in range(1, k):
        if n % i == 0:
            s.append(i)
            s.append(int(n // i))
    s = list(set(sorted(s)))
    return sorted(s)


n = int(input())
a = [int(i) for i in input().split()]
b = [0] * n
k = []
for i in range(n-1, -1, -1):
    if a[i] == 1:
        kk = calc(i+1)
        for kkk in kk:
            b[kkk-1] += a[i]
            b[kkk-1] = b[kkk-1] % 2
    if b[i] == 1:
        k.append(i+1)
if a == b:
    print(len(k))
    for kk in k:
        print(kk)
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int, input().split()))
b = [-1]*N
d = 1
r = []
for i in range(N, 0, -1):
  m = 0
  c = 2*i
  while c <= N:
    m += a[c-1]
    c += i
  if m % 2 == a[i-1]:
    b[i-1] = 0
  else:
    b[i-1] = 1
    r.append(i)
print(sum(b))
print(" ".join([str(s) for s in r]))

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int, input().split()))
b = [-1]*N
d = 1
r = []
for i in range(N, 0, -1):
  m = 0
  c = 2*i
  while c <= N:
    m += a[c-1]
    c += i
  if m % 2 == 1:
    break
  else:
    b[i-1] = a[i-1]
    if b[i-1] == 1:
      r.append(i)
else:
  print(sum(b))
  print(" ".join([str(s) for s in r]))
  exit()
print(-1)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int, input().split()))
b = [-1]*N
d = 1
for i in range(N, 0, -1):
  i -= 1
  m = 0
  for j in range(N//(i+1)-1):
    m += a[i*(j+2)]
  if m % 2 == 1:
    break
  else:
    b[i] = a[i]
else:
  print(sum(b))
  print(" ".join([str(s) for s in b if s == 1]))
  exit()
print(-1)

Submission status: Wrong Answer

Solution code:
import sys

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

for i in range(N):
  if a[i] == 1 :
    print("1")
    print(i+1)	
    sys.exit()

print("0")

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int, input().split()))
 
b = [ 0 for _ in range(N)]
#M = 0
for i in reversed(range(1, N+1)):
    summ = 0
    #b_summ = 0
    for j in range(i, N+1, i):
        summ += b[j-1]
        #b_summ += b[j-1]
    #if summ % 2 != a[i-1]:
    #	b[i-1] = 1
    #	M += 1
    divs = summ % 2
    b[i-1] = divs
 
cnt = sum(b)
print(cnt)
not_first = False
if cnt > 0:
 
    for j in range(N):
        if b[j] == 1:
            if not_first:
                print(" ", end="")
            print(j+1, end="")
            not_first = True
    print()

Submission status: Wrong Answer

Solution code:
def solve(n, a):
    box = [0] * (n + 1)
    for i in reversed(range(1, n + 1)):
        j = 2
        count = 0
        while i * j < n:
            if box[i * j] == 1:
                count += 1
            j += 1
        if a[i - 1] != count % 2:
            box[i] = 1
    ans = [str(i) for i, it in enumerate(box) if it == 1]
    return len(ans), ans


if __name__ == '__main__':
    N = int(input())
    A = list(map(int, input().split()))
    m, b = solve(N, A)
    print(m)
    if m > 0:
        print(' '.join(b))

Submission status: Wrong Answer

Solution code:
def solve(n, a):
    box = [0] * n
    for i in reversed(range(n)):
        j = 2
        count = 0
        while (i + 1) * j < n:
            if box[(i + 1) * j - 1] == 1:
                count += 1
            j += 1
        if a[i] != count % 2:
            box[i] = 1
    ans = [str(i + 1) for i, it in enumerate(box) if it == 1]
    return len(ans), ans


if __name__ == '__main__':
    N = int(input())
    A = list(map(int, input().split()))
    m, b = solve(N, A)
    print(m)
    if m > 0:
        print(' '.join(b))

Submission status: Wrong Answer

Solution code:
def solve(n, a):
    box = [0] * n
    for i in reversed(range(n)):
        j = 2
        count = 0
        while (i + 1) * j < n:
            if box[(i + 1) * j] == 1:
                count += 1
            j += 1
        if a[i] != count % 2:
            box[i] = 1
    ans = [str(i + 1) for i, it in enumerate(box) if it == 1]
    return len(ans), ans

if __name__ == '__main__':
    N = int(input())
    A = list(map(int, input().split()))
    m, b = solve(N, A)
    print(m)
    if m > 0:
        print(' '.join(b))

Submission status: Wrong Answer

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

    res = [0] * (N + 1)

    for i in range(N, 0, -1):
        res[i] = (sum(res[2 * i::i]) % 2) ^ an[i - 1]

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


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

def uoo(i):
    i += 1
    res = 0
    tmp = i
    while N>=i:
        res += A[i-1]
        i += tmp
    return res

result = []

for i in range(N-1,-1,-1):
    ball_sum = uoo(i)
    if (ball_sum-A[i])%2 != A[i]:
        result.append(i+1)

if result:
    print(len(result))
    print(*result)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
N=int(input())
a=list(map(int,input().split()))
M=0
b=[]
M=0
for i in range(N):
    b.append(0)
for j in range(N,0,-1):
    cnt=0
    for k in range(j,N,j):
        cnt+=b[k-1]
    if cnt%2!=a[j-1]:
        b[j-1]=1
        M+=1
c=[l+1 for l, x in enumerate(b) if x==1]
c=list(map(str,c))
print(M)
print(' '.join(c))

Submission status: Wrong Answer

Solution code:
N=int(input())
a=list(map(int,input().split()))
M=0
b=[]
M=0
for i in range(N):
    b.append(0)
for j in range(N,0,-1):
    cnt=0
    for k in range(j,N,j):
        cnt+=b[k-1]
    if cnt%2!=a[j-1]:
        b[j-1]=1
        print(b)
        M+=1
c=[l+1 for l, x in enumerate(b) if x==1]
c=list(map(str,c))
print(M)
print(' '.join(c))

Submission status: Wrong Answer

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

sum_index = [0]*(N+1)
index = []
for i in range(N)[::-1]:
    sum_ = 0
    for j in sum_index[i+1::i+1]:
        sum_ ^= j
    sum_index[i+1] = sum_ ^ A[i]
    if sum_index[i+1] == 1:
        index.append(str(i))

print(sum(sum_index))
if index:
    print(" ".join(index))

Submission status: Wrong Answer

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

sum_index = [0]*(N+1)
index = []
for i in range(N)[::-1]:
    sum_ = 0
    for j in sum_index[i+1::i+1]:
        sum_ ^= j
    sum_index[i+1] = sum_ ^ A[i]
    if sum_index[i+1] == 1:
        index.append(str(i))
print(sum(sum_index))
print(" ".join(index))

Submission status: Wrong Answer

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

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

p = 2**n
b = 0
for i in range(p):
	ok = True
	for j in range(n):
		res = 0
		for k in range(j,n):
			if (k+1) % (j+1) == 0:
				res ^= (b & (2 ** j))
		if res != a[j]:
			ok = False
			b+=1
			break
	if ok:
		break

num = 0
ans = []
index = 1
while b > 0:
	num += b % 2
	if b % 2:
		ans.append(index)
	b //= 2
	index += 1
if num==0:
	ans.append(0)
print(num)
for i in ans:
	print(i,end = ' ')
print()

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
b = [0 for _ in range(len(a) + 1)]
for i in range(len(a)):
    ri = len(a) - i
    if sum(b[::ri]) % 2 != a[ri - 1]:
        b[ri] = a[ri - 1]
b = b[1:]
print(len(str(b).split("1"))-1)
for i in range(len(b)):
    if b[i]:
        print(i + 1, end="")
        print(" ", end="")

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
b = [0 for _ in range(len(a) + 1)]
for i in range(len(a)):
    ri = len(a) - i
    if sum(b[::ri]) % 2 != a[ri - 1]:
        b[ri] = a[ri - 1]
b = b[1:]
print(len(str(b).split("1"))-1)
for i in range(len(b)):
    if b[i]:
        print(i, end="")
        print(" ", end="")

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
b = [0 for _ in range(len(a) + 1)]
for i in range(len(a)):
    ri = len(a) - i
    if sum(b[::ri]) % 2 != a[ri - 1]:
        b[ri] = a[ri - 1]
b = b[1:]
print(len(str(b).split("1"))-1)
for i in range(len(b)):
    if b[i]:
        print(i, end="")
        print(" ", end="")

Submission status: Wrong Answer

Solution code:
def main():
    n = int(input())
    a = [str(x) for x in input().split()]
    b = [str(0) for _ in range(n)]

    for i in range(n-1,-1,-1):
        cnt =0
        for j in range(i,n):
            if (j+1)%(i+1)==0 and a[j]=="1":
                cnt +=1
        if cnt%2==1 and a[i]=="1":
            b[i]= "1"
    ans1 = 0
    ans2 = []
    for i in range(n):
        if b[i]=="1":
            ans1+=1
            ans2.append(str(i+1))
    print(ans1)
    print(" ".join(ans2))
    
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
b = [0 for _ in range(len(a) + 1)]
for i in range(len(a)):
    ri = len(a) - i
    if sum(b[::ri]) % 2 != a[ri - 1]:
        b[ri] = a[ri - 1]
b = b[1:]
for i in range(len(b)):
    if b[i]:
        print(1, end="")
        print(" ", end="")

Submission status: Wrong Answer

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

B = [0 for _ in range(N)]
for i in range(N-1,-1,-1):
  isum = 0
  itr = 2
  while (i+1)*itr -1 < N:
    isum += A[(i+1)*itr - 1]
    itr += 1
  isum %= 2
  if isum != A[i]:
    B[i] = 1

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

Submission status: Wrong Answer

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

B = [0 for _ in range(N)]
for i in range(N-1,-1,-1):
  isum = 0
  itr = 2
  while (i+1)*itr -1 < N:
    isum += A[(i+1)*itr - 1]
    itr += 1
  isum %= 2
  if isum != A[i]:
    B[i] = A[i]

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

Submission status: Wrong Answer

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

boxes = [0]*(N+1)  # 後に最初の要素を取り除く

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

boxes = boxes[1:]

ans_n = sum(boxes)
ans_list = []

for i in range(len(A)):
    if A[i] == 1:
        ans_list.append(i)
print(ans_n)
if ans_n != 0:
    print(" ".join(map(str, ans_list)))

Submission status: Wrong Answer

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

for i in range(2, n+1):
        for j in range(n//(i-1)-1, n//i-1, -1):
                for k in range(1, i): ans[j] += ans[j*k]
                ans[j] %= 2
                ans[j] += abs(ans[j]-a[j])
                ans[j] %= 2
ans[0] = sum(ans)
ans[0] %=2

ans[0] += abs(ans[0]-a[0])
ans[0] %= 2

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

# 実際の index が i + 1 に対応することに注意
for i in range(N - 1, -1, -1):
    if i + 1 > N // 2:
        ans[i] = a[i]
    else:
        res = 0
        for j in range(N // (i + 1)):
            res += a[(i) * (j + 1)]
        ans[i] = res % 2

b = []
for k in range(N):
    if ans[k] == 1:
        b.append(str(k + 1))

print(sum(ans))
print(" ".join(b))

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
b=[0]*n
ans=[]
anscnt=0
for i in range(n-1,-1,-1):
    ai=a[i]
    j=2*(i+1)-1
    while n>j:
        ai^=b[j]
        j+=i+1
    if ai==1:
        b[i]=1
        ans.append(1)
        anscnt+=1
print(anscnt)
if anscnt>0:
    print(*ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
b=[0]*n
ans=[]
for i in range(n-1,-1,-1):
    ai=a[i]
    j=2*(i+1)-1
    while n>j:
        ai^=a[j]
        j+=i+1
    if ai==1:
        ans.append(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()))
b=[0]*n
ans=[]
for i in range(n-1,-1,-1):
    ai=a[i]
    j=i+1
    while n>j:
        ai^=a[j]
        j+=i+1
    if ai==1:
        ans.append(1)
print(len(ans))
if len(ans)>0:
    print(*ans)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
n = int(input())
a = tuple(map(int,input().split()))
b = [0] * n
for i in range(n,0,-1):
  c = 0
  for j in range(2,n//i):
    c += b[j*i-1]
  b[i-1] = (a[i-1] - c) % 2
print(sum(b))
print(' '.join(map(str,[i for i in range(n) if b[i-1] == 1])))

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
n = int(input())
a = tuple(map(int,input().split()))
b = [0] * n
for i in range(n,0,-1):
  c = 0
  for j in range(2,n//i):
    c += b[j*i-1]
  b[i-1] = (a[i-1] - c) % 2
print(sum(b))
print(' '.join(map(str,b)))

Submission status: Wrong Answer

Solution code:
n = int(input())
data = [int(_) for _ in input().split(" ")]

for i in range(len(data),0,-1):
    count = n//i
    for k in range(count, 1 ,-1):
        data[i-1] -= data[i*k-1]
    if data[i-1] < 0:
        print(-1)
        exit()

m = 0
for ele in data:
    if ele != 0:
        m += 1

print(m)
if m != 0:
    ans = []
    for i in range(len(data)):
        if data[i] != 0:
            ans.append(i+1)
    print(" ".join(map(str,ans)))

Submission status: Wrong Answer

Solution code:
n = int(input())
data = [int(_) for _ in input().split(" ")]

for i in range(len(data),0,-1):
    count = n//i
    for k in range(count, 1 ,-1):
        data[i-1] -= data[i*k-1]
    if data[i-1] < 0:
        print(-1)
        exit()

m = 0
for ele in data:
    if ele != 0:
        m += 1

print(m)
if m != 0:
    print(" ".join(["1" for i in range(m)]))

Submission status: Wrong Answer

Solution code:
from collections import deque
import sys
a = int(input())
flags = [int(i) for i in input().split()]

errorend = False
balls = deque()
balling =[]
for i in range(a):
    balls.appendleft(0)

for i in reversed(range(0, a)):
    temp = 0
    for j in range(i, a, i + 1):
        temp += balls[j]
    if flags[i] == 1:
        if temp % 2 == 0:
            balls[i] = 1
            balling.append(i + 1)
        else:
            balls[i] = 0
    else:
        if temp % 2 == 0:
            balls[i] = 0
        else:
            balls[i] = 1
            balling.append(i + 1)

if balls[0] == 0:
    if flags[0] == 1:
        print('-1')
        sys.exit()
if flags[0] == 1:
    if flags[0] != 1:
        print('-1')
        sys.exit()

m = balls.count(1)
print(m)
if m != 0:
    for i in balling:
      print(i, end=' ')

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!

box_num = int(input())
ball_in_box_num_list = [[int(i), []] for i in input().split(" ")]
for i in range(1, box_num + 1):
    k = 2
    while i * k <= box_num:
        ball_in_box_num_list[i * k - 1][1].append(i - 1)
        k += 1
ans_num = 0
ans_list = []
for i in range(box_num):
    a = box_num - 1 - i
    b = ball_in_box_num_list[a]
#     if b[0] == 1:
#         ans_num += 1
#         ans_list.append(a + 1)
#         for j in b[1]:
#             ball_in_box_num_list[j] = 1 - ball_in_box_num_list[j]
# print(ans_num)
# if ans_list != 0:
#     ans_list = [str(i) for i in ans_list]
#     ans_list = ans_list[::-1]
#     print(" ".join(ans_list))

Submission status: Wrong Answer

Solution code:
n = int(input())
A = [0] + [int(a) for a in input().split()]
B = [0]*(n+1)
B[-1] = A[-1]
for i in range(n-1,0,-1):
    a = A[i]
    for j in range(i,n+1,i):
        a += B[j]
    B[i] = a%2
s = sum(B)
print(s)
if s != 0:
    print(*[int(b) for b in B if b==1])

Submission status: Wrong Answer

Solution code:
n = int(input())
A = [0] + [int(a) for a in input().split()]
B = [0]*(n+1)
B[-1] = A[-1]
for i in range(n-1,0,-1):
    a = A[i]
    for j in range(i,n+1,i):
        a += A[j]
    B[i] = a%2
s = sum(B)
print(s)
if s != 0:
    print(*[int(b) for b in B if b==1])

Submission status: Wrong Answer

Solution code:
n = int(input())
A = [0] + [int(a) for a in input().split()]
B = [0]*(n+1)
B[-1] = A[-1]
for i in range(n-1,-1,-1):
    a = A[i]
    for j in range(i,n+1,i+1):
        a += A[j]
    B[i] = a%2
s = sum(B)
print(s)
if s != 0:
    print(*[int(b) for b in B if b==1])

Submission status: Wrong Answer

Solution code:
print(0)

Submission status: Wrong Answer

Solution code:
N=int(input())
A=[]
B=[]
C=[]
x=0
for i in range(N):
    B.append(0)
A=list(map(int,input().split()))
for i in reversed(range(N)):
    a=i+1
    b=N//a
    c=0
    for j in range(b):
        d=a*(j+1)
        c=c+B[d-1]
    e=c%2
    if e==A[i]:
        x=x+0
        B[i]=0
    else:
        x=x+1
        B[i]=1
        C.append(A[i])
if x==0:
    print(0)
else:
    print(x)
    print(*C)

Submission status: Wrong Answer

Solution code:
N=int(input())
A=[]
B=[]
for i in range(N):
    B.append(0)
A=list(map(int,input().split()))
for i in reversed(range(N)):
    a=i+1
    b=N//a
    c=0
    for j in range(b):
        d=a*(j+1)
        c=c+B[d-1]
    e=c%2
    if e==A[i]:
        B[i]=0
    else:
        B[i]=1
C=sum(B)
if C==0:
    print(0)
else:
    print(C)
    print(*B)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = [-1] + list(map(int, input().split()))
b = [-1] + [0 for _ in range(N)]

for i in range(N+1):
    unfeasible = False
    if a[i] != b[i]:
        for j in range(N):
            if b[i * j] == 0:
                b[i * j] = 1
                break
            elif i * j > N:
                print(-1)
                unfeasible = True
                break
    if unfeasible:
        break

b = b[1:]
b_index = []
for i, n in enumerate(b):
    if n == 1:
        b_index.append(str(i+1))

print(len([n for n in b if n == 1]))
if len(b_index) > 0:
    print(' '.join(b_index))

Submission status: Wrong Answer

Solution code:
N = int(input())
a = [-1] + list(map(int, input().split()))
b = [-1] + [0 for _ in range(N)]

for i in range(N+1):
    if a[i] != b[i]:
        for j in range(N):
            if b[i * j] == 0:
                b[i * j] = 1
                break
            elif i * j > N:
                print(-1)
                exit()

b = b[1:]
b_index = []
for i, n in enumerate(b):
    if n == 1:
        b_index.append(str(i+1))

print(len([n for n in b if n == 1]))
print(' '.join(b_index))

Submission status: Wrong Answer

Solution code:

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

ans=[]

for i in range(1,n+1):
    if ans!=[]:
        break
    for j in [x for x in range(1,1+n)if x%i==0]:
        if a[j-1]==1:
            ans+=[j]

cnt=len(ans)
if cnt>0:
    print(cnt)
    for i in ans:print(i)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
N=int(input())
result=[0]*N
resnum=0
flag=0
box=list(map(int,input().split(" ")))
for m in range(N):
    num=0
    sum=0
    while (m+1)*num<N+1:
        sum+=box[(m+1)*num-1]
        num+=1
    if sum%2==1:
        result[m]=1
        resnum+=1
print(resnum)
for n in range(N):
    if result[n]==1:
        if flag==1:
            print(" "+str(n+1),end="")
        else:
            flag=1
            print(n+1,end="")

Submission status: Wrong Answer

Solution code:
import numpy as np

N = int(input())

A = input()
A = A.split()

A = np.array(A)

flg = True
list = ""

count = 0

for i in range(1, N+1, 1):
    times = int(N / i)
    times = int(times / 2)
    if times % 2 == 1:
        list = list + str(i)
        count = count + 1

if count == 0:
    print(count)
else:
    print(count)
    print(list)

Submission status: Wrong Answer

Solution code:
import numpy as np

N = int(input())

A = input()
A = A.split()

A = np.array(A)

flg = True
list = ""

count = 0

for i in range(1, N+1, 1):
    times = int(N / i)
    times = int(times / 2)
    if times % 2 == 1:
        list = list + str(i)
        count = count + 1

if count == 0:
    print(-1)
else:
    print(count)
    print(list)

Submission status: Wrong Answer

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

b = [0]*N
for i in reversed(range(N)):
    j = i + 1
    buf = b[i::j]
    if (sum(buf) % 2) != a[i]:
        b[i] = 1
print(sum(b))
bb = [i+1 for i in range(len(a)) if a[i] == 1]
if sum(b) != 0:
    print(' '.join(map(str, bb)))

Submission status: Wrong Answer

Solution code:
import numpy as np

N = int(input())
a = []
a = list(map(int,input().split()))
a_np = np.array(a)

b = [0]*N
for i in reversed(range(N)):
    j = i + 1
    buf = b[i::j]
    if (sum(buf) % 2) != a[i]:
        b[i] = 1
print(sum(b))
bb = [i+1 for i in range(len(a)) if a[i] == 1]
print(' '.join(map(str, bb)))

Submission status: Wrong Answer

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

for s in range(n**2):
    judge=True
    for i in range(1,n+1):
        cnt=0
        for j in range(i,n+1,i):
            if s >> (j-1) & 1 == 1:
                cnt += 1
        if cnt % 2 != a[i-1]:
            judge=False
            break
    if judge and s == 0:
        print("0")
        print("0")
        exit()
    elif judge:
        temp=str(bin(s))
        tempt=temp[2:]
        tempt=tempt[::-1]
        ans=[]
        for j in range(len(tempt)):
            if tempt[j]=="1":
                ans.append(j+1)
        print(len(ans))
        if len(ans)==1:
            print(ans[0])
        else:
            print(" ".join(ans))
        exit()
print("-1")

Submission status: Wrong Answer

Solution code:
def get_divisor(i, n):
    out = [0] * (n // i)
    for j in range(len(out)):
        out[j] = i * j
    return out

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

B = [False] * n

for i in range(n, 0, -1):
    divisors = get_divisor(i, n)
    B[i-1] = bool(A[i-1]) ^ bool(sum(B[divisor-1] for divisor in divisors) % 2)

out = [str(i+1) for i in range(n) if B[i-1]]

print(sum(B))
print(" ".join(out))

Submission status: Wrong Answer

Solution code:
def get_divisor(i, n):
    out = [0] * (n // i)
    for j in range(len(out)):
        out[j] = i * j
    return out

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

B = [False] * n

for i in range(n, 0, -1):
    divisors = get_divisor(i, n)
    B[i-1] = bool(A[i-1]) ^ bool(sum(B[divisor-1] for divisor in divisors) % 2)

out = [str(i) for i in range(n) if B[i-1]]

print(sum(B))
print(" ".join(out))

Submission status: Wrong Answer

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

ans = -1

tf_li = []
b_li = []
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors
tf_li = [True if i == 0 else False for i in li]

for i in reversed(range(0, n)):
    if tf_li[i] == False:
        b_li.append(i+1)
        for j in make_divisors(i+1):
            print(j)
            if tf_li[j-1]:
                tf_li[j-1] = False
            else:
                tf_li[j-1] = True

if False not in tf_li:
    print(len(b_li))
    print(" ".join(map(str, b_li)))
else:
    print("-1")

Submission status: Wrong Answer

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

b = [0] * (N + 1)
half = int(N / 2)
if N != 1:
    b[half:] = A[half - 1:]
for i in range(N, 1, -1):
    s = sum([b[j] for j in range(i * 2, N + 1, i)]) % 2
    if s != A[i - 1]:
        b[i] = 1
s = sum(b)
if s % 2 != A[0]:
    b[1] = 1
    s += 1
print(s)
for i, b_ in enumerate(b[:]):
    if b_ == 1:
        print(i, end=" ")

Submission status: Wrong Answer

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

b = [0] * (N + 1)
half = int(N / 2)
if N != 1:
    b[half:] = A[half - 1:]
for i in range(N, 0, -1):
    s = sum([b[j] for j in range(i * 2, N + 1, i)]) % 2
    if s != A[i - 1]:
        b[i] = 1
s = sum(b)
if s % 2 != A[0]:
    b[1] = 1
    s += 1
print(s)
for i, b_ in enumerate(b[:]):
    if b_ == 1:
        print(i, end=" ")

Submission status: Wrong Answer

Solution code:
n = int(input())
data = [int(_) for _ in input().split(" ")]

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

#half
half_index = n//2

for i in range(half_index,n):
    ans[i] = data[i]

for i in range(half_index-1,-1,-1):
    count = n//(i+1)
    ans[i] = data[i]
    if i != 1:
        while count != 1:
            ans[i] = ans[i] - ans[count*i-1]
            count -= 1
    else:
        while count != 1:
            ans[0] = ans[0] - ans[count-1]
            count -= 1

count = 0
for _ in ans:
    if _ != 0:
        count += 1

print(count)

ans2 = ["1" for i in range(count)]
if sum(ans) != 0:
    print(" ".join(map(str,ans2)))

Submission status: Wrong Answer

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

box = [0] * N
v = N // 2  # 後半部の最初のindex

for i in range(v, N):
    if ai[i] == 0:
        box[i] = 0
    else:
        box[i] = 1

for i in range(v - 1, -1, -1):
    value = i + 1
    sum = 0
    for j in range(value * 2 - 1, N, value):
        sum += box[j]
    if sum & 1 == 1:
        box[i] = 0 if ai[i] & 1 == 1 else 1
    else:
        box[i] = 0 if ai[i] & 1 == 0 else 1
print(box)

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