Problem:


Score : 400 points

Problem Statement

There are N empty boxes arranged in a row from left to right.
The integer i is written on the i-th box from the left (1 \leq i \leq N).

For each of these boxes, Snuke can choose either to put a ball in it or to put nothing in it.

We say a set of choices to put a ball or not in the boxes is good when the following condition is satisfied:

For every integer i between 1 and N (inclusive), the total number of balls contained in the boxes with multiples of i written on them is congruent to a_i modulo 2.

Does there exist a good set of choices? If the answer is yes, find one good set of choices.

Constraints

All values in input are integers.

1 \leq N \leq 2 \times 10^5

a_i is 0 or 1.

Input

Input is given from Standard Input in the following format:

N
a_1 a_2 ... a_N

Output

If a good set of choices does not exist, print -1.

If a good set of choices exists, print one such set of choices in the following format:

M
b_1 b_2 ... b_M

where M denotes the number of boxes that will contain a ball, and b_1,\ b_2,\ ...,\ b_M are the integers written on these boxes, in any order.

Sample Input 1

3
1 0 0

Sample Output 1

1
1

Consider putting a ball only in the box with 1 written on it.

There are three boxes with multiples of 1 written on them: the boxes with 1, 2, and 3. The total number of balls contained in these boxes is 1.

There is only one box with a multiple of 2 written on it: the box with 2. The total number of balls contained in these boxes is 0.

There is only one box with a multiple of 3 written on it: the box with 3. The total number of balls contained in these boxes is 0.

Thus, the condition is satisfied, so this set of choices is good.

Sample Input 2

5
0 0 0 0 0

Sample Output 2

0

Putting nothing in the boxes can be a good set of choices.



Sample input:
3
1 0 0


Sample output:
1
1

Submission status: Wrong Answer

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

'''
10
1 1 0 0 1 0 1 0 1 0


1 1 1 0 1 0 1 0 1 0
'''
result = [0] * N
for i in range(N):
    #print(N-i)
    if A_list[N-i-1] == 1 and (N-i)*2 >= N:
        result[N-i-1] = 1
    if A_list[N-i-1] == 0 and (N-i)*2 >= N:
        result[N-i-1] = 0
    if A_list[N-i-1] == 1 and (N-i)*2 < N:
        tmp_sum =0
        for r in range(0,N,N-i):
            tmp_sum +=result[r]
        if  tmp_sum % 2 == 0:
            result[N-i-1] = 1
        if  tmp_sum % 2 == 1:
            result[N-i-1] = 0
    if A_list[N-i-1] == 0 and (N-i)*2 < N:
       tmp_sum =0
       for r in range(0,N,N-i):
           tmp_sum +=result[r]
       if  tmp_sum % 2 == 0:
           result[N-i-1] = 0
       if  tmp_sum % 2 == 1:
           result[N-i-1] = 1

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

Submission status: Wrong Answer

Solution code:
N=int(input())
A = [int(a) for a in input().split()]
#print(N,A)
B = [0]*N
for i in reversed(range(N)):
  if 2*(i+1)-1 <= N-1:
    B[i] = (A[2*(i+1)-1]+A[i])%2
  else:
    B[i] = A[i]
#print(B)
C = [str(i+1) for i,b in enumerate(B) if b == 1]
print(len(C))
print(" ".join(C))

Submission status: Wrong Answer

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

if c%2 == 1 and c > 1:
    print('-1')
else:
    print(c)
    print(" ".join(repr(e) for e in ans))

Submission status: Wrong Answer

Solution code:
# D
N = int(input())

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

X=[0]*N
for i in range(N, 0, -1):
    j=1
    tmp=0
    while(i*j<=N):
        tmp+=a[i*j-1]
        j+=1
    X[i-1] = tmp%2

if (sum(X[1:])%2==a[0]):
    X[0] = 0
else:
    X[0] = 1
    
print(sum(X))
for i, j in enumerate(X):
    if j == 1:
        print(str(i+1) + " ", 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 reversed(range(1, N+1)):
    summ = 0
    b_summ = 0
    for j in range(i, N+1, i):
        summ += a[j-1]
        b_summ += b[j-1]
    divs = (summ - b_summ) % 2
    b[i-1] = divs

cnt = sum(b)
print(cnt)
if cnt > 0:
    for j in range(N):
        if b[j] == 1:
            print(j+1, end="")
    print()

Submission status: Wrong Answer

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

import math

if __name__ == '__main__':
    N = int(input())
    A = [int(c) for c in input().split()]
    R = [0 for i in range(N)]
    M = 0

    for i in range(N-1, -1, -1):
        # print('i={}'.format(i))
        start = i
        sum = 0
        for j in range(start, N, i + 1):
            # print('  j={}'.format(j))
            sum += R[j]
        # print(sum)
        # print(A[i])
        if sum % 2 != A[i]:
            R[i] = 1
            M += 1

    # print(R)

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

Submission status: Wrong Answer

Solution code:
import numpy as np
n = int(input())
an = np.array(input().split(" ")).astype("int64")

if an[0] == 0:
  print("0")
else:
  print("1")
  print("1")

Submission status: Wrong Answer

Solution code:
import math
def isPrime(n):
    if n == 1:
        return False

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

    return True

def Solve():
    flag=True
    PL=[]
    N=int(input())
    L=[int(x) for x in input().split()]
    for i in range(N):
        if i==0:
            continue
        j=i+1
        if sum(L[i::j])%2-L[i]:#ちがったらTrue
            if isPrime(j):#素数ならTrue
                L[i]=0 if L[i]==1 else 1#L[i]を入れ替え（どうせ大勢に影響はない）
            else:
                print(-1)
                return
                
    if sum(L)-L[0]:#ちがったらTrue
        L[0]=0 if L[0]==1 else 1

    print(sum(L))
    result=""
    for i,a in enumerate(L):
        if a:
            result+=str(i+1)
            result+=" "
    if result:
        print(result)
    
Solve()

Submission status: Wrong Answer

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

flag = -1
counter = 0

while(True):
    if counter == N // 2:
        break

    total = sum(A[i] for i in range(counter, N, counter+1))
    if total % 2 == A[counter]:
        flag = counter + 1
        break
    
    counter += 1


if flag != -1:
    res = [str(i+1) for i in range(counter, N, counter+1) if A[i] == 1]
    print(len(res))
    if len(res) != 0:
        print(' '.join(res))
else:
    for i in range(counter, N):
        if A[i] == 1:
            flag = i
            print(1)
            print(i+1)
            break

if flag == -1:
    print(flag)

Submission status: Wrong Answer

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

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

if len(b) >= 1:
    print(len(b))
    for i in range(len(b)):
        print(str(b[i]) + " ", end="")
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
input = sys.stdin.readline

##### リストの 二分木検索 #####
# bisect_left(lists, 3)
# bisect_right(lists, 3)

##### プライオリティキュー #####
# heapq.heapify(a) #リストaのheap化
# heapq.heappush(a,x) #heap化されたリストaに要素xを追加
# heapq.heappop(a) #heap化されたリストaから最小値を削除＆その最小値を出力

# heapq.heappush(a, -x) #最大値を取り出す時は、pushする時にマイナスにして入れよう
# heapq.heappop(a) * (-1) #取り出す時は、-1を掛けて取り出すこと

##### タプルリストのソート #####
# sorted(ans) #(a, b) -> 1st : aの昇順, 2nd : bの昇順
# sorted(SP, key=lambda x:(x[0],-x[1])) #(a, b) -> 1st : aの昇順, 2nd : bの降順
# sorted(SP, key=lambda x:(-x[0],x[1])) #(a, b) -> 1st : aの降順, 2nd : bの昇順
# sorted(SP, key=lambda x:(-x[0],-x[1])) #(a, b) -> 1st : aの降順, 2nd : bの降順

# sorted(SP, key=lambda x:(x[1])) #(a, b) -> 1st : bの昇順
# sorted(SP, key=lambda x:(-x[1])) #(a, b) -> 1st : bの降順

def main():

	N = int(input())
	# = list(input())
	#L,R = map(int, input().split(" "))
	#L = list(map(int, input().split(" ")))
	P = getPrimeNumList(200000)
	A = input().split()

	ans = []

	for i, val in enumerate(A):
		tmp = i+1
		if tmp == 1 and int(val) == 1:
			ans.append(tmp)
			continue
		if tmp in P:
			if int(val) == 1:
				ans.append(tmp)

	print(len(ans))
	if len(ans) != 0:
		ans2 = ""
		for i in reversed(ans):
			ans2 = ans2 + str(i) + " "

		print(ans2[:-1])

def getPrimeNumList(n):
	is_prime = [True] * (n + 1)
	is_prime[0] = False
	is_prime[1] = False
	for i in range(2, int(n**0.5) + 1):
		if not is_prime[i]:
			continue
		for j in range(i * 2, n + 1, i):
			is_prime[j] = False
	return [i for i in range(n + 1) if is_prime[i]]

if __name__ == "__main__":
	main()

Submission status: Wrong Answer

Solution code:
def primes(x):
  is_prime = [True] * (x + 1)
  is_prime[0] = False
  is_prime[1] = False
  for i in range(2, int(x**0.5) + 1):
    if not is_prime[i]:
      continue
    for j in range(i * 2, x + 1, i):
      is_prime[j] = False
  return [i for i in range(x + 1) if is_prime[i]]

n=int(input())
P=primes(n)
pp=len(P)
A=[int(i) for i in input().split()]
Ans=[]
C=[False]*n
for i in reversed(range(n)):
  if A[i]==1:    
    if 2*(i+1)>n:
      Ans.append(i+1)
      C[i]=True
    else:
      c=1
      j=0
      while j<pp and P[j]*(i+1)<=n:
        if C[P[j]*(i+1)-1]==True:
          c^=1
        j+=1
      if c==1:
        Ans.append(i+1)
        C[i]=True
  elif A[i]==0:    
    c=0
    j=0
    while j<pp and P[j]*(i+1)<=n:
      if C[P[j]*(i+1)-1]==True:
        c^=1
      j+=1
    if c==0:
      Ans.append(i+1)
      C[i]=True
if len(Ans)==0:
  print(0)
else:
  print(len(Ans))
  Ans.sort()
  print(*Ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = map(int, raw_input().split())
ANS = []

for j in range(N, 0, -1):
    s = 0
    for k in range(j, N, j):
        if A[k-1] == 1:
            s += 1

    am = s % 2
    if A[j-1] != am:
        A[j-1] += 1
        ANS.append(j)

print(len(ANS))
str_ANS = [str(j) for j in ANS]
print(" ".join(str_ANS))

Submission status: Wrong Answer

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

for i in range(int(n/2)+1,n+1):
    b[i]=a[i]

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

if any(b)==False:
    print(0)
else:
    def func1(lst, value):
        return [i for i, x in enumerate(lst) if x == value]
    idx=func1(b,1)
    print(' '.join(map(str, idx)))

Submission status: Wrong Answer

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

ball = [False for _ in range(n)]

ans = []
for i, a in enumerate(reversed(box)):
    #print("{} {}".format(i,a))
    idx = n - 1 - i
    count_right = 0
    p = 2
    j = (idx + 1) * p
    #print("{} <= {}".format(j,n))
    while j <= n:
        #print("w {} {}".format(idx,n))
        if ball[j-1]:
            count_right += 1
        p+=1
        j = (n - idx + 1)  * p
    if a != 0:
        if (count_right % 2) != 0:
            ball[idx] = False
        else:
            ball[idx] = True
            ans.append(idx+1)
    else:
        if (count_right % 2) != 0:
            ball[idx] = True
            ans.append(idx+1)
        else:
            ball[idx] = False

ans_len = len(ans)
print(ans_len)
if (int(ans_len) == 0):
    pass #print('exit')
else:
    ans_s = ""
    for i, b in enumerate(ball):
        if b:
            if ans_s == "":
                ans_s = str(i+1)
            else:
                ans_s += " "
                ans_s += str(i+1)
    print(ans_s)
    #    if a != 0:
    #        ball[idx] = True

Submission status: Wrong Answer

Solution code:
n = int(input())
a = input().split(' ')

b = [int(x) for x in a]

c = []
for i in range(n):
    c.append(0)

d=[]

for i in range(n):
    i = n - i - 1
    s = 0
    for j in range(i+1,n):
        if (j+1)%(i+1) == 0:
            s = s + c[j]
    if s%2 != b[i]:
        c[i] = 1
        d.append(i+1)

print(sorted(d))

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int, input().split()))
dp = [0] * (N + 1)
for i in range(N, 0, -1):
  #print(i)
  if i > N // 2:
    dp[i] = a[i - 1]
  else:
    j = 3
    dp[i] = dp[2 * i] ^ a[2 * i - 1]
    if i <= N // 3:
      dp[i] = dp[3 * i] ^ a[3 * i - 1]
      if i <= N // 6:
        dp[i] = dp[6 * i] ^ a[6 * i - 1]
      while i * j <= N:
        dp[i] = dp[i] ^ dp[i * j]
        j += 2
        if j % 3 == 0:
          j += 2
    else:
      while i * j <= N:
        dp[i] = dp[i] ^ dp[i * j]
        j += 2
    dp[i] = dp[i] ^ a[i - 1]
M = 0
res2 = ""
#print(dp)
for i, v in enumerate(dp):
  if v == 1:
    M += 1
    res2 += str(i) + " "
print(M)
print(res2)

Submission status: Wrong Answer

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

flag = True
ans = []
for i in range(1, int(N**1/2)+1):  # 0番目は最後に参照すればよい
    one = 0
    zero = 0
    if A[0] == 0:
        zero = 1
    else:
        one = 1

    for j in range(i, N, i):
        if A[j] == 0:
            zero += 1
        else:
            one += 1

    if abs(zero-one) <= 1:
        for _ in range(abs(zero-one)):
            ans.append(i)
            i += i
    else:
        flag = False
        break


if flag:
    print(len(ans))
    print(" ".join(map(str, ans)))
else:
    if sum(A) == 0:
        print(0)
    else:
        print(-1)

Submission status: Wrong Answer

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

def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]

prime_list = primes(N)

dps = [0 for _ in range(N)]

ans =[]
#半分までは確定
fs = N // 2
for i in range(fs, N):
    dps[i] += A[i]
    if A[i] == 1:
        ans.append(i+1)


for i in reversed(range(fs)):
    # 考慮すべき数i*素数 < N
    num = 0
    for p in prime_list:
        if (i+1) * p <= N:
            num += dps[(i+1) * p - 1]

    
    if num % 2 != A[i]:
        dps[i] += 1
        ans.append(i+1)


print(len(ans))
if len(ans) != 0:
    print(" ".join(map(str, ans)))

Submission status: Wrong Answer

Solution code:
import numpy as np
n=int(input())
als=input().split()
for i in range(n):
    als[i]=int(als[i])
bls=np.zeros(n)

if n>=3:
    for i in range(2):
        if als[n-1-i]==1:
            bls[n-1-i]=1

    for i in range(n-2):
        m=n-2-i
        sum=0
        b=n//m
        for j in range(b):
            sum+=bls[j*m-1]
        if sum%2!=als[m-1]:
            bls[m-1]=1

    ans=[i for i, x in enumerate(bls) if x ==1]
    print(len(ans))
    L=[str(a+1) for a in ans]
    L=" ".join(L)
    print(L)

elif n==2:
    if als[1]==1:
        bls[1]=1
    if int(bls[1]+bls[0])!=als[0]:
        bls[0]=1
    ans=[i for i, x in enumerate(bls) if x ==1]
    print(len(ans))
    L=[str(a+1) for a in ans]
    L=" ".join(L)
    print(L)

else:
    if als[0]==1:
        bls[0]=1
    ans=[i for i, x in enumerate(bls) if x ==1]
    print(len(ans))
    L=[str(a+1) for a in ans]
    L=" ".join(L)
    print(L)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int,input().split()))
total = sum(a)
if total%2 == 0 and a[0] == 1:
    print(-1)
    exit()
elif total%2 == 1 and a[0] == 0:
    print(-1)
    exit()
b = []
counter = 0
for i in range(N-1,-1,-1):
    n = i+1
    total = 0
    for j in range(n,N+1,n):
        total += a[j-1]
    total -= a[i]
    if total%2 == 0 and a[i] == 0:
        pass
    elif total%2 == 0 and a[i] == 1:
        counter += 1
        b.append(n)
    else:
        print(-1)
        exit()
if counter == 0:
    print(counter)
else:
    b.sort()
    print(counter)
    print(*b, sep=" ")

Submission status: Wrong Answer

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

    count = 0  
    printlist = []

    count = 0
    printlist = []
    for i in range(N//2,N):
        boxes[i] = A[i]
        if A[i] == 1:
            count = 1
            printlist.append(i)
    for i in range(N//2):
        s = A[i]
        #print('i=',i)
        for j in range(2,N//(i+1)+1):
            #print('idx=',(i+1)*j - 1)
            s ^= boxes[(i+1)*j - 1]
        boxes[i] = s
        if s == 1:
            count += 1

            printlist.append(i)

    import sys
    print(count)
    for i in printlist:
        sys.stdout.write(str(i+1))
        sys.stdout.write(' ')
    print()

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

flag = True
ans = []
for i in range(1, int(N**1/2)+1):  # 0番目は最後に参照すればよい
    one = 0
    zero = 0
    if A[0] == 0:
        zero = 1
    else:
        one = 1

    for j in range(i, N, i):
        if A[j] == 0:
            zero += 1
        else:
            one += 1

    if abs(zero-one) <= 1:
        for _ in range(one):
            ans.append(i)
            i += i
    else:
        flag = False
        break


if flag:
    print(len(ans))
    print(" ".join(map(str, ans)))
else:
    if sum(A) == 0:
        print(0)
    else:
        print(-1)

Submission status: Wrong Answer

Solution code:

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

M = 0
ans_lst = [0] * N
Nt = N
Nn = Nt // 2


while Nt > 1:
    for i in range(Nn, Nt):
        t = 0
        for j in range(i, N, i+1):
            t += a_lst[j]
        t -= a_lst[i]
        t %= 2
        ans_lst[i] = (a_lst[i] + t) % 2

    Nt = Nn
    Nn = Nt // 2
    


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

if (m + 1) % 2 == a_lst[0]:
    ans_lst[0] = 1
else:
    ans_lst[0] = 0

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

else:
    print(-1)

Submission status: Wrong Answer

Solution code:
N=int(input())
listA=list(map(int,input().split()))
listB=[0 for i in range(N)]
listANS=[]
for i in range(N-1,-1,-1):
  listN=listA[i:N:i+1]
  if len(listN)==1 and listA[i]==1:
    listB[i]=1
  elif len(listN)>1 and sum(listN)%2!=sum(listB[0:N:i+1])%2:
    listB[i]=1
for i in range(N):
  if listB[i]==1:
    listANS+=[i+1]
ANS=len(listANS)
print(ANS)
if ANS!=0:
  print(*listANS)

Submission status: Wrong Answer

Solution code:
N = int(input())
a_l = list(map(int,input().split()))
ans_l = {}
for i,a in enumerate(a_l[::-1]):
    index = N-i
    curnum = 0
    for j in range(2,N//2):
        if(index*j<=N):
           curnum += ans_l[index*j]
        else:
            break
    if(curnum%2!=a):
        ans_l[index] = 1
    else:
        ans_l[index] = 0

inlist = []
ans_len = 0
for key,num in ans_l.items():
    if(num==1):
        inlist.append(key)
        ans_len+=1

ans_str = " ".join(list(map(str,sorted(inlist))))
print(ans_len)
if(ans_str != ""):
    print(ans_str)

Submission status: Wrong Answer

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

balls = list()
# for i, a in enumerate(reversed(A)):
for bn in range(n, 0, -1):
    a = A[bn - 1]
    if 2*bn > n:
        if a == 1:
            balls.append(str(bn))
    else:
        a2 = A[2*bn - 1]
        if a != a2:
            balls.append(str(bn))

all_balls = len(balls)
if all_balls % 2 != A[0]:
    print(-1)
else:
    print(all_balls)
    print(' '.join(balls))

Submission status: Wrong Answer

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

n=int(input())
a=[int(i) for i in input().split()]
ans=[0]*n
for i in range(n-1,-1,-1):
    if a[i]==1:
        chk=0
        for j in range(2,n+1):
            if (i+1)*j<=n and a[(i+1)*j-1]:
                chk+=1
        if chk%2==0:
            ans[i]=1
print(ans.count(1))
if sum(ans):
    ans2=[]
    for i in range(n):
        if ans[i]:
            ans2.append(i+1)
    print(*ans2)

Submission status: Wrong Answer

Solution code:
#https://atcoder.jp/contests/abc134/tasks/abc134_d
import sys
input = sys.stdin.readline

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

b = [0] * n
for i in reversed(range(1, n + 1)):
    s = 0
    for j in range(i + 1, n + 1, i):
        s += a[j - 1]
    if s % 2 == a[i - 1]:
        b[i - 1] = 0
    else:
        b[i - 1] = 1
#print(b)
e = sum(b)
print(e)

if e != 0:
    d = []
    for i in range(n):
        if b[i] == 1:
            d.append(i + 1)
    print(' '.join(map(str, d)))

Submission status: Wrong Answer

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

s = 0
M = 0

hantei = True
for i in range(1,N+1):
    for j in range(1,N//i+1):
        s = s + a[j*i]
    if s % 2 == a[i] : 
        b = []
        for j in range(1,N//i+1):
            if a[j*i] == 1: 
                M = M + 1
                b.append(j*i)
        print(M)
        for j in range(M):
            print(b[j],end='')
        hantei = False
        break

    s = 0
if hantei : print('-1')

Submission status: Wrong Answer

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

s = set()


def primes(n):
    erat=[False,False]+[True for i in range(n-1)]
    for i in range(n + 1) :
        if erat[i]:
            for j in range(i*2,n+1,i):
                erat[j]=False
    return [i for i in range(n+1)if erat[i]]

ps = primes(n)

def change(i):
    if a[i] == 1: a[i] = 0
    else: a[i]= 1


for i in range(n,0,-1):
    if a[i] == 1:
        s.add(i)
        yakusu=[x for x in ps if i%x==0]
        for x in yakusu:
            change(a[x])

print(len(s))
[print(x) for x in s]

Submission status: Wrong Answer

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

if N % 2 == 0:
    k = N // 2
    x = [0] * k + a[k:]
    start = k
else:
    k = (N + 1) // 2
    x = [0] * (k - 1) + a[k - 1:]
    start = k - 1

for i in range(start, 0, -1):
    x[i - 1] = (sum(x[i::i]) + a[i - 1]) % 2

M = 0
b = []
for i in range(N):
    if x[i] == 1:
        M += 1
        b.append(str(i + 1))
print(M)
print(' '.join(b))

Submission status: Wrong Answer

Solution code:
import sys

input = sys.stdin.readline


def main():
    n = int(input())
    a_list = [int(i) for i in input().split()]
    print(0)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

import math

if __name__ == '__main__':
    N = int(input())
    A = [int(c) for c in input().split()]
    R = [0 for i in range(N)]

    for i in range(N-1, -1, -1):
        # print('i={}'.format(i))
        start = i
        sum = 0
        for j in range(start, N, i + 1):
            # print('  j={}'.format(j))
            sum += R[j]
        # print(sum)
        # print(A[i])
        if sum % 2 != A[i]:
            R[i] = 1

    print(R)

Submission status: Wrong Answer

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

a.insert(0,0)

for i in range(int(n/2),n+1):
    b[i]=a[i]

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

if any(b)==False:
    print(0)
else:
    def func1(lst, value):
        return [i for i, x in enumerate(lst) if x == value]
    idx=func1(b,1)
    print(' '.join(map(str, idx)))

Submission status: Wrong Answer

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

result = []
res_ap = result.append

for i in range(N // 2, N)[::-1]:
    if a[i] == 1:
        res_ap(i)
for i in range(N // 2)[::-1]:
    if a[i] == 0:
        res_ap(i)
M = len(result)
print(M)
if M != 0:
    print(result[0] + 1, end = "")
    for i in range(1, M):
        print(" " + str(result[i] + 1), end = "")

Submission status: Wrong Answer

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

shoki = N // 2
A.insert(0, -1)
N += 1
boxes = [0 for i in range(N)]
result = []

N -= 1
for i in range(N, shoki):
    boxes[i] = A[i]
    if A[i] == 1:
        result.append(i)

for i in range(shoki, 0, -1):
    mul = 2
    val = i
    cnt = 0
    while val*mul <= N:
        if boxes[val*mul] == 1:
            cnt += 1
        mul += 1
    if A[i] == 0 and (cnt % 2) == 0:
        boxes[i] = 0
    elif A[i] == 0:
        boxes[i] = 1
        result.append(i)
    elif A[i] == 1 and (cnt % 2) == 0:
        boxes[i] = 1
        result.append(i)
    else:
        boxes[i] = 0
if result:
    print("1")
    print(*result)
else:
    print("0")

Submission status: Wrong Answer

Solution code:
N=int(input())
a=list(map(int, input().split()))
n=N//2
b=[None]*N
for i in range(n,N):
        b[i]=a[i]
for i in range(n-1,0,-1):
        c=0
        t=2*i+1
        while t<N:
                if b[t]==1:
                        c+=1
                t+=(i+1)
        b[i]=(c+a[i])%2
M=b.count(1)
if a[0]==0:
        b[0]=M%2
else:
        b[0]=(M+1)%2
if b[0]==1:
        print(M+1)
else:
        print(M)
for i in range(N):
        if b[i]==1:
                print(i+1,end=" ")

Submission status: Wrong Answer

Solution code:
import numpy as np
n = int(input())
a = [int(i) for i in input().split()] 

a = np.array(a)
ls = a
def func(ind):
    tmp = list(range(2*ind-1, n, ind))
    s = ls[tmp].sum()
    return s%2

st = int(n/2)
for ind in range(st, 0, -1):
    if a[ind-1] == func(ind):
        ls[ind-1] = 0
    else:
        ls[ind-1] = 1
        
print(sum(ls))
ans = np.where(ls==1)[0]+1
print(list(ans))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
f_ans = -1
f_ans_index = 0
for i in range(n):
    ans = 0
    cnt = i+1
    count = 2
    while cnt <= n:
        ans += a[cnt-1]
        cnt *= count
        count += 1
    if ans%2 == a[i]:
        f_ans = sum(a)
        f_ans_index = i+1
        break
if f_ans == 0:
    print(0)
else:
    print(f_ans)
    print(f_ans_index)

Submission status: Wrong Answer

Solution code:
N=int(input())
box=[1]*N
a_list=list(map(int,input().split()))
sum=0
for i in range(N-1,-1,-1):
    word=a_list[i]
    k=i
    for j in range(2,N):
        if j*(i+1) <= N:
            if box[j*(i+1)-1]==1:
                sum+=1
        else:
            break
    i=k
    if word == 0:
        if sum%2 == 0:
            box[i]=0
    else:
        if sum%2 == 1:
            box[i]=0
    sum=0
ans=[]
sum=0
for i,k in enumerate(box):
    if k==1:
        sum+=1
        ans.append(str(i+1))
print(sum)
print(" ".join(ans))

Submission status: Wrong Answer

Solution code:
# from sys import exit, stderr
# from inspect import currentframe
# def debug(*args):
#     names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}
#     print(', '.join(names.get(id(arg),'???')+' = '+repr(arg) for arg in args), file=stderr)
#     return
N = int(input())
a = [int(_) for _ in input().split()]
b = set()
out = []
n = 0
for i in range(N-1, -1, -1):
    if a[i] == 1:
        tmp = 1
        for e in b:
            tmp *= e
        for o in out:
            if o % (i+1) == 0:
                a[i] += 1
                a[i] %= 2
        if a[i] == 0:
            continue
        while((tmp+1)%(i+1) != 0):
            tmp += 1
        out.append(tmp + 1)
        a[i] = 0
        n += 1
    b.add(i+1)
print(n)
# print(b)
if len(out) > 0:
    for i in range(len(out)):
        print(out[i], end=" ")
    print()

Submission status: Wrong Answer

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

res = [0]

for idx, i in enumerate(reversed(b_list)):
    if sum(res[::len(b_list)-idx]) % 2 == i:
        res.append(0)
    else:
        res.append(1)

print(sum(res))
del res[0]

for idx, i in enumerate(reversed(res)):
    if i == 1:
        print(idx+1, end=' ')

Submission status: Wrong Answer

Solution code:
N = int(input())
As = [int(i) for i in input().split(" ")]
Bs = [0 for _ in range(N)]
for i in reversed(range(N)):
  n = i + 1
  a = As[i]
  if not (a == 1 and Bs[i] % 2 == 0 or a == 0 and Bs[i] % 2 == 1): continue
  k = 1
  while k <= n:
    if n % k == 0:
      Bs[k-1] += 1
      Bs[k-1] %= 2
    k += 1
ans = [b for b in Bs if b == 1]
print(len(ans))
for i, b in enumerate(Bs):
    if b == 1:
       print(i + 1, end=" ")
print()

Submission status: Wrong Answer

Solution code:
N = int(input())

A = [0]*N
B = [0]*N

A = [int(x) for x in input().split()]


q = N//2

B[q:] = A[q:]

for i in range(q)[::-1]:
	s = 0
	j = i
	while j < N:
		s += A[j]
		j += i+1
	if s%2 != A[i]:
		B[i] = 1

print(sum(B))

f = 0
if sum(B)!=0:
	j = 0
	for i in range(N):
		if B[i] != 0:
			if f==0:
				print(i+1, end='')
				f += 1
			else:
				print(' '+str(i+1), end='')
	print()

Submission status: Wrong Answer

Solution code:
import sys

N = int(input())

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

b = [0] * N

for i in range(N-1, -1, -1):
    sum = 0
    for j in range(2, N):
        if i * j < len(a):
            sum += a[i*j]
        else:
            break
    if sum % 2 == 1:
        b[i] = 1

num = 0
for i in range(N):
    if b[i] == 1:
        num += 1

print(num)

if num == 0 or num == -1:
    sys.exit(0)

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

print("")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
l = list(map(int,input().split()))
u = []
m = n
b = 0
count = 0
for i in range(2,n+1):
    while(m>n//i):
        b=0
        for j in range(1,i):
            b = b^l[m*j-1]
            #print(b,m*j)
        if(b):
            u.append(m)
            count += 1
        m -= 1
b = 0
for i in range(0,n):
    b = b^l[i]
if(b):
    u.append(m)
    count += 1
print(count)
if(u):
    print(*list(reversed(u)))

Submission status: Wrong Answer

Solution code:
n = int(input())
ai = list(map(int,input().split()))
ans = [0 for i in range(n)]

while n != 0:
  for i in range(int(n/2),n):#後半の処理
    ans[i] = ai[i]
    if ai[i] ==1:
      for j in range(int((i+1)/2)):#前半の処理
        if(i+1)%(j+1) ==0:
          ai[j] = 1 - ai[j]
  n = int(n/2)
if ai[0] == ans[0]:
  print(sum(ans))
  if (sum(ans) == 0):
    print(0)
    exit(0)
  else:
    for i in range(len(ans)):
      if(ans[i] == 1):
        print('{} '.format(i+1),end='')
else:
  print(-1)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [int(i) for i in input().split()]
b = []
b = [i+1 for i in range(n//2,n) if a[i] == 1]

for i in reversed(range((n//2))):
    if a[i] != len([x for x in b if x%(i+1) == 0])%2:
        b=[i+1] + b
        
print(len(b))
print(b)