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
sys.setrecursionlimit(4100000)

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

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(4100000)

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

Submission status: Wrong Answer

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

r = [None] * N
# A = A[::-1]  # 扱いやすくするためにひっくり返す

# nの倍数の箱に入っているボールの個数
# (nは含まない)
def f(n):
    i = 2
    cnt = 0
    while n * i < N:
        # print('-', n, i, r)
        cnt += r[(n * i)-1]
        i += 1
    return cnt

n = N
while n > 0:
    c = f(n)
    if c % 2 == A[n-1]:
        r[n-1] = 0
    else:
        r[n-1] = 1
    n -= 1

# print(r)

if r.count(0) == N:
    print(0)
else:
    for i, ri in enumerate(r):
        if ri == 1:
            print(i+1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
N=int(input())
a=list(map(int,input().split()))
a0 = a[0]
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
ma = N
mi = N//2
for i in range(len(bin(N))-2):
    for j in range(ma,mi,-1):
        if a[j-1]%2==1:
            tg_list = make_divisors(j)
            for k in tg_list:
                if k!=j:
                    a[k-1] += 1
    #a[mi//2:mi] %= 2
    #print(a)
    ma = mi
    mi = mi//2
if sum(a)%2 == a0:
    #print(a)
    res = [str(i+1) for i in range(N) if a[i]%2==1]
    M = len(res)
    if M!=0:
        print(' '.join(res))
else:
    print(-1)

Submission status: Wrong Answer

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

Bo = [1 for _ in range(n)]
Ans = []

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

    if (tot % 2 == A[i]) and (A[i] == 0):
        pass
    elif (tot % 2 == A[i]) and (A[i] == 1):
        Ans.append(str(i+1))
    else:
        pass
if len(Ans) ==0:
    print(0)
else:
    print(len(Ans))
    print(' '.join(Ans))

Submission status: Wrong Answer

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

print(-1)

Submission status: Wrong Answer

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

a = [0]+a
ball = [0]+ball

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

Submission status: Wrong Answer

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

n = int(input())

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

ans = []

a = a[::-1]

for i, x in enumerate(a):
  j = n-i
  tmp = 0
  
  k = 1
  
  baisu = [(n//j) * k for k in range(n//j)]
  
  for k in baisu:
    if (k+1) * j in ans:
	    tmp += 1
    
  if tmp % 2 != x:
    ans.append(j)

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

Submission status: Wrong Answer

Solution code:
import numpy as np
n = int(input())
a = [int(i) for i in input().split()]
#x = np.zeros(n,dtype=int)
x = [0]*(n+1)
for i in reversed(range(1,n+1)):
  tmp = 0
  for j in range(2*i,n+1,i):
    if x[j] == 1:
      tmp += 1
  if tmp % 2 != a[i-1]:
    x[i] = 1
#no ball
if all(i == 0 for i in x):
  print(0)
  exit()
#else
for i in range(1,n+1):
  if x[i] == 1:
    print(i,end=" ")

Submission status: Wrong Answer

Solution code:
import numpy as np
n = int(input())
a = [int(i) for i in input().split()]
x = np.zeros(n,dtype=int)
for i in range(n//2,n):
  if a[i] == 1:
    x[i] = 1
for i in reversed(range(n//2)):
  tmp = 0
  for j in range(i,n,i+1):
    if x[j] == 1:
      tmp += 1
  if tmp % 2 != a[i]:
    x[i] = 1
#no ball
if all(i == 0 for i in x):
  print(0)
  exit()
#else
for i in range(n):
  if x[i] == 1:
    print(i+1,end=" ")

Submission status: Wrong Answer

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

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

print(sum(b))
if ans==[]:
    ans.append(0)
print(' '.join(map(str, ans)))

Submission status: Wrong Answer

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

box=[0]*n
ans=[]
for i in range(n,0,-1):
    sum_=0
    for j in range(1,n+1):
        if j*i>n:
            break
        sum_+=box[j*i-1]
    if sum_%2!=a[i-1]:
        box[i-1]=1
        ans.append(i)

print(len(ans))
if len(ans)==0:
    print(0)
else:
    print(' '.join(list(map(str,ans))))

Submission status: Wrong Answer

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

B = [0] * N
for i in reversed(range(N)):
    ball = 0
    j = i + 1
    while j < N:
        ball += B[j - 1]
        j *= 2

    if ball % 2 != A[i]:
        B[i] = 1


print(sum(B))
print(*[i for i, b in enumerate(B, start=1) if b == 1], sep=' ')

Submission status: Wrong Answer

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

B = [0] * N
for i in reversed(range(N)):
    ball = 0
    j = i + 1
    while j < N:
        ball += B[j]
        j *= 2

    if ball % 2 != A[i]:
        B[i] = 1


print(sum(B))
print(*[i for i, b in enumerate(B, start=1) if b == 1], sep=' ')

Submission status: Wrong Answer

Solution code:
# 後ろから判定してエラトステネスっぽく更新していく

n = int(input())
arr = list(map(int, input().split()))
boxes = [0 for _ in range(n)]

for i in range(n, 0, -1):
    # print("i = {}".format(i))
    tmp = arr[i - 1]
    for j in range(i + i - 1, n, i):
        # print("   j = {}".format(j))
        tmp += arr[j]
        tmp %= 2
    # print("tmp = {}".format(tmp))
    if boxes[i - 1] != tmp:
        # print("ということで変更")
        # arr[i - 1] += 1
        # arr[i - 1] %= 2
        boxes[i - 1] += 1

# print(boxes)
ans = list(filter(lambda v: v[1] > 0, enumerate(boxes)))
print(len(ans))
if len(ans) > 0:
    ans = list(map(lambda x: str(x[0] + 1), ans))
    print(" ".join(ans))

Submission status: Wrong Answer

Solution code:
# 後ろから判定してエラトステネスっぽく更新していく

n = int(input())
arr = list(map(int, input().split()))
boxes = [0 for _ in range(n)]

for i in range(n, 0, -1):
    # print("i = {}".format(i))
    tmp = 0
    for j in range(i - 1, n, i):
        # print("j = {}".format(j))
        tmp += arr[j]
        tmp %= 2
    # print("tmp = {}".format(tmp))
    if arr[i - 1] != tmp:
        arr[i - 1] += 1
        arr[i - 1] %= 2
        boxes[i - 1] += 1

ans = list(filter(lambda v: v[1] > 0, enumerate(boxes)))
print(len(ans))
if len(ans) > 0:
    ans = list(map(lambda x: str(x[0] + 1), ans))
    print(" ".join(ans))

Submission status: Wrong Answer

Solution code:
n = int(input())
arr = list(map(int, input().split()))
boxes = [0 for _ in range(n)]

# 後ろから判定して更新していく
ans = 0
for i in range(n - 1, -1, -1):
    # 自分以降の自分の倍数箇所のボールの数（1が立ってる箇所）を数える
    c = 0
    for j in range(i, n, max(i, 1)):
        print("i, j = {}, {}".format(i, j))

        if arr[j] == 1:
            c += 1
    if boxes[i] != c % 2:
        # 自分自身に追加することで帳尻合わせできる
        boxes[i] = (boxes[i] + 1) % 2
        ans += 1

print(ans)
print(boxes)

# for i in range(n):
#     c = 0
#     for j in range(n - i - 1, n, n - i):
#         # print(j, end=" ")
#         if arr[j] == 1:
#             c += 1
#     # print()
#     # print("i={}, c={}".format(n - i - 1, c))
#     if arr[n - i - 1] != c % 2:
#         print("-1")
#         exit()

# # いけるパターンは、与えられた配列の1が立っているところ
# print(sum(arr))  # めんどいのでこれでいいや
# for i, v in enumerate(arr):
#     if v == 1:
#         print(i + 1)

Submission status: Wrong Answer

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

b = [0 for i in range(N//2)]+a[N//2:]

for i in range(N//2-1,-1,-1):
    if sum(b[i::i+1])%2 == 0:
        b[i] = a[i]
    else:
        b[i] = 1-a[i]

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

print(len(ans))
print(' '.join(map(str,ans)))

Submission status: Wrong Answer

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

b = [0 for i in range(N//2)]+a[N//2:]

for i in range(N//2-1,-1,-1):
    if sum(b[i::i+1])%2 == 0:
        b[i] = a[i]
    else:
        b[i] = 1-a[i]

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

Submission status: Wrong Answer

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

for i in reversed(range(1, N+1)):
    total = 0
    for j in range(i+i, N+1, i):
        total ^= b[j]
    b[i] = total ^ a[i]

ans_n = 0
ans_l = []
for i in range(N+1):
    if b[i]:
        ans_n += 1
        ans_l.append(str(i+1))

print(ans_n)
print(' '.join(ans_l))

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**9)
INF=10**18
def input():
    return sys.stdin.readline().rstrip()

def main():
    N=int(input())
    a=list(map(int,input().split()))
    l=[0]*N
    for i,x in enumerate(reversed(a)):
        z=N-i
        c=0
        for j in range(2,N//z+1):
            c+=l[z*j-1]
        if c%2!=x:
            l[N-1-i]+=1
    l2=[]
    for x in l:
        if x:
            l2.append(x)
    print(len(l2))
    print(*l2)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**9)
INF=10**18
def input():
    return sys.stdin.readline().rstrip()

def main():
    N=int(input())
    a=list(map(int,input().split()))
    l=[0]*N
    for i,x in enumerate(reversed(a)):
        z=N-i
        c=0
        for j in range(1,N//z):
            c+=l[z*j-1]
        if c%2!=x:
            l[N-1-i]+=1
    l2=[]
    for x in l:
        if x:
            l2.append(x)
    print(len(l2))
    print(*l2)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**9)
INF=10**18
def input():
    return sys.stdin.readline().rstrip()

def main():
    N=int(input())
    a=list(map(int,input().split()))
    l=[0]*N
    for i,x in enumerate(reversed(a)):
        z=N-i
        c=0
        for j in range(N//z-1):
            c+=l[z*j-1]
        if c%2!=x:
            l[N-1-i]+=1
    l2=[]
    for x in l:
        if x:
            l2.append(x)
    print(len(l2))
    print(*l2)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**9)
INF=10**18
def input():
    return sys.stdin.readline().rstrip()

def main():
    N=int(input())
    a=list(map(int,input().split()))
    l=[0]*N
    for i,x in enumerate(reversed(a)):
        z=N-i
        c=0
        for j in range(N//z-1):
            c+=l[z*j-1]
        if c%2!=x:
            l[N-1-i]+=1
    print(sum(l))
    l2=[]
    for x in l:
        if x:
            l2.append(x)
    print(*l2)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**9)
INF=10**18
def input():
    return sys.stdin.readline().rstrip()

def main():
    N=int(input())
    a=list(map(int,input().split()))
    l=[0]*N
    for i,x in enumerate(reversed(a)):
        z=N-i
        c=0
        for j in range(N//z-1):
            c+=l[z*j-1]
        if c%2!=x:
            l[N-1-i]+=1
    print(sum(l))
    for x in l:
        if x:
            print(x,end=' ')

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**9)
INF=10**18
def input():
    return sys.stdin.readline().rstrip()

def main():
    N=int(input())
    a=list(map(int,input().split()))
    l=[0]*N
    for i,x in enumerate(reversed(a)):
        z=N-i
        c=0
        for j in range(N//z-1):
            c+=l[z*j-1]
        if c%2!=x:
            l[N-1-i]+=1
    print(sum(l))
    for x in l:
        if x:
            print(x,end='')

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N = int(input())
L = list(map(int, input().split()))
balls = L.copy()

for i in reversed(range(N)):
    b = set()
    pow = 2
    while (i+1)*pow <= N:
        b.add(balls[i])
        pow += 1
    # print(b)
    # print('--')
    if len(b) > 1:
        print(-1)
        exit()
    if not b:
        balls[i] = L[i]
        continue
    if L[i] != list(b)[0]:
        if L[i] == 0:
            balls[i] = 1
        else:
            balls[i] = 0

ans_n = 0
ans_l = []
for i, ball in enumerate(balls):
    if ball:
        ans_n += 1
        ans_l.append(str(i+1))

print(ans_n)
if ans_l:
    print(' '.join(ans_l))

Submission status: Wrong Answer

Solution code:
import math


def is_prime(n):
    A = set([])

    for k in range(2, int(math.sqrt(n)) + 1, 2):
        if n % k == 0:
            A.add(n // k)
            break

    return A


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

for i in range(N - 1, 0, -1):
    a = A[i]
    b = B[i] = B[i] ^ a

    for p in is_prime(i + 1):
        B[p - 1] ^= b

B[0] = (sum(B) % 2) ^ A[0]

S = [i + 1 for i, c in enumerate(B) if c]

print(len(S))
print(*S)

Submission status: Wrong Answer

Solution code:
import math


def is_prime(n):
    A = set([])
    if n == 1:
        return A

    for k in range(2, int(math.sqrt(n)) + 1, 2):
        if n % k == 0:
            A.add(k)
            A.add(n // k)
            return A

    A.add(1)
    return A


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

for i in range(N - 1, -1, -1):
    a = A[i]
    b = B[i] = B[i] ^ a

    for p in is_prime(i + 1):
        B[p - 1] ^= b

S = [i + 1 for i, c in enumerate(B) if c]

print(len(S))
print(*S)

Submission status: Wrong Answer

Solution code:
import math


def is_prime(n):
    A = set([])
    if n == 1:
        return A

    for k in range(2, int(math.sqrt(n)) + 1, 2):
        if n % k == 0:
            A.add(k)
            A.add(n // k)
            return A

    A.add(1)
    return A


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

for i in range(N - 1, 0, -1):
    a = A[i]
    b = B[i] = B[i] ^ a

    for p in is_prime(i + 1):
        B[p - 1] ^= b

B[0] = A[0] ^ (sum(B) % 2)


S = [i + 1 for i, c in enumerate(B) if c]

print(len(S))
print(*S)

Submission status: Wrong Answer

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

for i in range(N - 1, -1, -1):
    p = A[i]
    j = i + 1
    while i < N:
        if B[i]:
            p ^= 1
        i += j

S = [i + 1 for i, c in enumerate(B) if c]

print(len(S))
print(*S)

Submission status: Wrong Answer

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

boxes=[0]*n #if ball in boxes[i-1]=boxes no.i
'''
b=[]
#m=len(b)
i=n #iの番号が書いた箱、インデックスはa[i-1]について
while i>=1:
	count=a[i-1]
	for j in range(i+1,n+1):
		if j%i==0:
			count+=boxes[j-1]
	boxes[i-1]=count%2
	if boxes[i-1]:
		b.append(i)
	i-=1
#print(boxes)

print(len(b))
print(*b) #space区切り
'''
for i in reversed(range(n)):
	boxes[i]=(a[i]+sum(boxes[i+1::i+1]))%2

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

Submission status: Wrong Answer

Solution code:
import math


def is_prime(n):
    A = set([])
    if n == 1:
        return A

    for k in range(2, int(math.sqrt(n)) + 1, 2):
        if n % k == 0:
            A.add(k)
            A.add(n // k)
            return A

    A.add(1)
    return A


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

for i in range(N - 1, 1, -1):
    a = A[i]
    b = B[i] = B[i] ^ a

    for p in is_prime(i + 1):
        B[p - 1] ^= b

B[0] = A[0] ^ (sum(B) % 2)


S = [i + 1 for i, c in enumerate(B) if c]

print(len(S))
print(*S)

Submission status: Wrong Answer

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

boxes=[0]*n #if ball in boxes[i-1]=boxes no.i
'''
b=[]
#m=len(b)
i=n #iの番号が書いた箱、インデックスはa[i-1]について
while i>=1:
	count=a[i-1]
	for j in range(i+1,n+1):
		if j%i==0:
			count+=boxes[j-1]
	boxes[i-1]=count%2
	if boxes[i-1]:
		b.append(i)
	i-=1
#print(boxes)

print(len(b))
print(*b) #space区切り
'''
for i in reversed(range(n)):
	boxes[i]=(a[i]+sum(boxes[i::i+1]))%2

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

Submission status: Wrong Answer

Solution code:
import math


def is_prime(n):
    A = set([])
    if n == 1:
        return A

    for k in range(2, int(math.sqrt(n)) + 1, 2):
        if n % k == 0:
            A.add(k)
            A.add(n // k)
            return A

    A.add(1)
    return A


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

for i in range(N - 1, 1, -1):
    a = A[i]
    b = B[i] = B[i] ^ a

    for p in is_prime(i + 1):
        B[p - 1] ^= b

B[0] = A[0] ^ (sum(B) % 2)


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

if len(S) == 0:
    print(0)
else:
    print(len(S))
    print(' '.join(S))

Submission status: Wrong Answer

Solution code:
import math


def is_prime(n):
    A = set([])
    if n == 1:
        return A

    for k in range(2, int(math.sqrt(n)) + 1, 2):
        if n % k == 0:
            A.add(k)
            A.add(n // k)
            return A

    A.add(1)
    return A


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

for i in range(N - 1, 1, -1):
    a = A[i]
    b = B[i]
    B[i] = (b % 2) ^ a

    for p in is_prime(i + 1):
        B[p - 1] ^= b

B[0] = A[0] ^ (sum(B) % 2)


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

if len(S) == 0:
    print(0)
else:
    print(len(S))
    print(' '.join(S))

Submission status: Wrong Answer

Solution code:
import math


def is_prime(n):
    if n == 1:
        return 1, 1

    for k in range(2, int(math.sqrt(n)) + 1, 2):
        if n % k == 0:
            return k, n // k

    return 1, n


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

for i in range(N - 1, 1, -1):
    a = A[i]
    b = B[i]
    B[i] = (b % 2) ^ a

    p, q = is_prime(i + 1)
    B[p - 1] += b + B[i]
    B[q - 1] += b + B[i]


B[0] = A[0] ^ (sum(B) % 2)


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

if len(S) == 0:
    print(0)
else:
    print(len(S))
    print(' '.join(S))

Submission status: Wrong Answer

Solution code:
import math


def is_prime(n):
    if n == 1:
        return 1, 1

    for k in range(2, int(math.sqrt(n)) + 1, 2):
        if n % k == 0:
            return k, n // k

    return 1, n


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

for i in range(N - 1, 1, -1):
    a = A[i]
    b = (B[i] % 2) ^ A[i]

    p, q = is_prime(i)
    B[p] += B[i] + b
    B[q] += B[i] + b

    B[i] = b


B[0] = A[0] ^ (sum(B) % 2)


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

if len(S) == 0:
    print(0)
else:
    print(len(S))
    print(' '.join(S))

Submission status: Wrong Answer

Solution code:
print("-1")

Submission status: Wrong Answer

Solution code:
n = int(input())

ar = list(map(int, input().split()))
result = [0 for i in range(n+1)]
num = 0
for i in range(n, 0, -1):
    flag = True
    for j in range(i, n+1, i):
        flag = flag ^ ar[j-1]
    if flag:
        result[i] = 0
    else:
        result[i] = 1
        num += 1
print(num)
for i in range(len(result)):
    if result[i] == 1:
        print(i)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
n = int(input())
al = list(map(int, input().split()))

bl = [0]*n
for i in range(n,0,-1):
    if i*2>n:
        if al[i-1]>0:
            bl[i-1] = 1
        continue

    c = 2
    s = 0
    while i*c<=n:
        s += bl[i*c-1]
        c += 1
    if al[i-1]==1:
        bl[i-1] = 1 if s%2==0 else 0
    else:
        bl[i-1] = 0 if s%2==0 else 1

print(*bl)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
ans=[0]*n
for i in range(n-1,-1,-1):
  x=(sum(ans[i::i+1]))%2
  if x!=a[i]:
    ans[i]=1
print(sum(ans))
if sum(ans)!=0:
  print(*ans,sep="")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    n = int(input())
    n_half = n // 2
    a = list(map(int, input().split()))
    ls = [0] * n
    ans = []

    for i in range(n-1, -1, -1):
        if (sum(ls[2*i:n:i+1]) % 2) != a[i]:
            ls[i] = 1
            ans.append(i+1)
        else:
            ls[i] = 0
    print(sum(ls))
    if ans:
        print(*ans[::-1])


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    n = int(input())
    a = list(map(int, input().split()))
    ls = [None] * n
    ans = []

    for i in range(n-1, -1, -1):
        if (sum(ls[i+1:n:i+1]) % 2) != a[i]:
            ls[i] = 1
            ans.append(i+1)
        else:
            ls[i] = 0
    print(sum(ls))
    if ans:
        print(*ans[::-1])


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    n = int(input())
    a = list(map(int, input().split()))
    ls = [None] * n
    ans = []

    for i in range(n-1, -1, -1):
        if (sum(ls[i+1:n:i+1]) % 2) != a[i]:
            ls[i] = 1
            ans.append(i+1)
        else:
            ls[i] = 0
    print(sum(ls))
    if ans:
        print(*ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    n = int(input())
    a = list(map(int, input().split()))
    ls = [None] * n
    ans = []

    for i in range(n-1, -1, -1):
        if sum(ls[i+1:n:i+1]) != a[i]:
            ls[i] = 1
            ans.append(i+1)
        else:
            ls[i] = 0
    print(sum(ls))
    if ans:
        print(*ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    n = int(input())
    a = list(map(int, input().split()))
    ls = [None] * n
    ans = []

    for i in range(n-1, -1, -1):
        if sum(ls[i+1:n]) != a[i]:
            ls[i] = 1
            ans.append(i+1)
        else:
            ls[i] = 0
    print(sum(ls))
    if ans:
        print(*ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
box=[0]*n
for i in range(n):
  baisu=n//(n-i)
  if baisu==1:
    box[n-i-1]=a[n-i-1]
  else:
    cnt=0
    for j in range(2,baisu+1):
      cnt+=box[(n-i-1)*j]
    if cnt%2!=a[n-i-1]:
      box[n-i-1]=1
print(sum(box))
if sum(box)!=0:
  for i in range(n):
    if box[i]==1:
      print(i+1,end=' ')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    A = [0] + list(map(int, input().split()))
    B = [0] * (N+1)
    for i in range(N,0,-1):
        tmp = 0
        for j in range(i,N+1,i):
            tmp ^= B[j]
        B[i] = tmp ^ A[i]

    ans = []
    for b in B:
        if b != 0:
            ans.append(b)

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



if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    A = [0] + list(map(int, input().split()))
    B = [0] * (N+1)
    for i in range(N,0,-1):
        tmp = 0
        for j in range(i,N+1,i):
            tmp += B[j]
        B[i] = (tmp % 2) ^ A[i]

    ans = []
    for b in B:
        if b != 0:
            ans.append(b)

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



if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    A = [0] + list(map(int, input().split()))
    B = [0] * (N+1)
    for i in range(N,0,-1):
        tmp = 0
        for j in range(i,N+1,i):
            tmp += A[j]
        B[i] = tmp % 2

    ans = []
    for b in B:
        if b != 0:
            ans.append(b)

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



if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
n = int(input())
*a, = map(int, input().split())
ans = [0] * n
for i in range(n-1, -1, -1):
    if not sum(ans[i::i+1]) == a[i]:
        ans[i] = 1
print(sum(ans))
print(*[i+1 for i in range(n) if ans[i] == 1])

Submission status: Wrong Answer

Solution code:
n = int(input())
*A, = map(int, input().split())
cnt = 0
ans = []
for i, a in enumerate(A[::-1]):
    flag = True
    for a1 in A[len(A)-i-1:len(A)+1:len(A)-i]:
        if a1 == 1:
            flag = False
            break
    if a == 1 and flag:
        ans.append(len(A)-i)
        cnt += 1
print(cnt)
if ans:
    print(*ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
*A, = map(int, input().split())
cnt = 0
ans = []
for i, a in enumerate(A[::-1]):
    flag = True
    for a1 in A[len(A)-i:len(A)+1:len(A)-i]:
        if a1 == 1:
            flag = False
            break
    if a == 1 and flag:
        ans.append(len(A)-i)
        cnt += 1
print(cnt)
if ans:
    print(*ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
*A, = map(int, input().split())
cnt = 0
ans = []
for i, a in enumerate(A[::-1]):
    flag = True
    for a1 in A[len(A)-i:len(A)+1:len(A)-i]:
        if a1 == 1:
            flag = True
            break
    if a == 1:
        ans.append(len(A)-i)
        cnt += 1
print(cnt)
if ans:
    print(*ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
*A, = map(int, input().split())
cnt = 0
ans = []
for i, a in enumerate(A[::-1]):
    if a == 1:
        ans.append(len(A)-i)
        cnt += 1
print(cnt)
if ans:
    print(*ans)

Submission status: Wrong Answer

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

#箱の状態を記録しておく配列
box=[0]*n


for i in range(1,n):
  num=n-i

  #まず割って、その数より大きい倍数がいくつあるか探る
  baisu=n//num

  if baisu==1:
    box[num-1]=a[num-1]

  #1～baisu倍の箱の状態を調べる。
  temp=0
  for j in range(2,baisu+1):
    temp+=box[num*j-1]
  box[num-1]=abs(temp%2-a[num-1])

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

if sum(ans)!=0:
  print(len(ans))
  print(*ans)
else:
  print("0")

Submission status: Wrong Answer

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

#箱の状態を記録しておく配列
box=[0]*n


for i in range(1,n):
  num=n-i

  #まず割って、その数より大きい倍数がいくつあるか探る
  baisu=n//num

  if baisu==1:
    box[num-1]=a[num-1]

  #1～baisu倍の箱の状態を調べる。
  temp=0
  for j in range(2,baisu+1):
    temp+=a[num*j-1]
  box[num-1]=abs(temp%2-a[num-1])

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

if sum(ans)!=0:
  print(len(ans))
  print(*ans)
else:
  print("0")

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

Solution code:
def main():

    N = int(input())
    a = {i: inp for i, inp in enumerate(map(int, input().split()), 1)}
        
    b = {i : 0 for i in range(1, N+1)}
    ret = []

    for i in range(N, 0, -1):
        sum_multiple = 0
        cursor = 2
        while i * cursor <= N:
            sum_multiple += a[i * cursor]
            cursor += 1

        if a[i] == 1:
            if sum_multiple % 2 == 0:
                b[i] = 1
                ret.append(i)
        else:
            if sum_multiple % 2:
                b[i] = 1
                ret.append(i)

    M = len(ret)
    print(M)
    if M:
        ret = ' '.join([str(i) for i in ret])
        print(ret)

if __name__=="__main__":
    main()