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=[0]
r=list(map(int,input().split()))
for i in range(n):
  a.append(r[i])
b=[0 for i in range(n+1)]


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

  j=2
  b[i]=a[i]
  while(j*i<n):
    b[i]^=a[j*i]
    j+=1

m=0
for i in range(n):
  m+=b[i]

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

Submission status: Wrong Answer

Solution code:
n = int(input())
figure = list(map(int, input().split()))
error = 0#０だと正常
one = []
for i in range(n):
  if figure[i] == 1:
    one.append(i)
print(one)
for x in range(n):
  a = 0
  for i in range(x,n,x+1):
    if figure[i] == 1:
      a +=1
#  print("a",a)
  if figure[x] != (a%2):
    error += 1
    print("-1")
    break
if error == 0:
  data = list(map(lambda x:x+1, one))
  if not data:
    print("0")
  else:
    print(*data)

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

st = int(n/2)
print(sum(a))
for ind in range(st, 0, -1):
    tmp = list(range(2*ind-1, n, ind))
    s = ls[tmp].sum()%2
    if a[ind-1] == s:
        ls[ind-1] = 0
    else:
        ls[ind-1] = 1
        print(ind)

Submission status: Wrong Answer

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

def get_index(n):
    return [i for i in range(2 * n, N + 1, n)]


def f():
    F = set()
    for n in range(N, 1, -1):
        index = get_index(n)
        # print(n, index)
        a = sum([A[i] for i in index]) % 2
        if a != A[n]:
            F.add(n)

    if len(F) % 2 != A[1]:
        F.add(1)

    return F

F = f()
print(len(F))
# if len(F) != 0:
L = list(map(str, F))
print(" ".join(L))

Submission status: Wrong Answer

Solution code:

N =  int(input())
good_pattern = [int(i) for i in input().split()]
finder = False

for i in range(2 ** N):
  pattern = [int(i) for i in list(format(i,'b').zfill(N))]
  judge_arr = []
  for j in range(N):
    multiple_list = [a for a in range(N+1) if a % (j+1) == 0][1:]
    sums = 0
    for k in multiple_list:
      sums += pattern[k-1]
      
    judge = sums%2
    judge_arr.append(judge)
  print(judge_arr)
    
  if judge_arr == good_pattern:
    finder = True 
    break

if finder:
  print("Yes")

else:
  print(-1)

Submission status: Wrong Answer

Solution code:
import numpy as np
n = int(input())
an = np.array(input().split(" ")).astype("int64")
if an[0] == 0:
    if n % 2 == 0:
        print("0")
    elif n % 2 == 1:
        print("1")
        print("1")
elif an[0] == 1:
    if n % 2 == 0:
        print("1")
        print("1")
    elif n % 2 == 1:
        print("0")

Submission status: Wrong Answer

Solution code:
n = int(input())

a = input().split()
a = [int(i) for i in a]
result = []
check = True
for i in range(len(a)):
    tmp = [a[j] for j in range(i, len(a), i + 1)] 
    if sum(tmp) == 0:
        result.append(0)
    elif sum(tmp)%2 == (i + 1):
        result.append(i + 1) 
    else:
        check = False

if check:
    out = ""
    if sum(result) == 0:
        print(0)
    else:
        count = 0
        for r in result:
            if r != 0:
                out = str(r) + " "
                count += 1
        print(count)
        print(out[:-1])
else:
    print("-1")

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)
b[0]=(M+a[0])%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:
N = int(input())
a = [0] + list(map(int,input().split()))
li = [0]*(N+1)
for i in range(N//2+1,N+1):
    if a[i]==1:
        li[i]+=1
for j in range(N//2,0,-1):
    if sum(li[j::j])%2!=a[j] and sum(li[j::j])%2==0:
        li[j]+=1
print(li)
li2 = [i for i, x in enumerate(li) if x == 1]

if len(li2)==0:
    print(0)
    exit()
for k in range(len(li2)):
    print(li2[k],end="")

Submission status: Wrong Answer

Solution code:
import sys
n=int(input())
a=list(map(int,input().split()))
b=[]
d=[]
ans=0
e=0
if a[0]==1:
  c=1
  ans+=1
if a[0]==0:
  c=+0
b.append(c)
c=0
A=a.count(1)
if a[0]==0 and A>0:
  print("-1")
for i in range(2,n+1):
  for j in range(i-1,(n//i)*i,i):
    if a[j]==1:
      c+=1
  b.append(c)
  c=0
for k in range(n):
  if b[k]==1:
    ans+=1
    d.append(1)
  else:
    e+=1
if e==1:
  print("-1")
else:
  print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input()) 
a = [int(i) for i in input().split()]
#print(a)
m = a.copy()
# m[n//2:] = a[n//2:]
for i in reversed(range(n//2)):
	for j in reversed(range(2,1 + n//(i+1))):
		m[i] = m[i]^m[j*i]
print(sum(m))
for i in range(n):
	if m[i] == 1:
		print(i+1)

Submission status: Wrong Answer

Solution code:
def inpl():
    return list(map(int, input().split()))


def func(n):
    for j in range(1, int(n**0.5) + 1):
        if n % j == 0:
            ans[n // j - 1] += 1
            ans[j - 1] += 1
    return


N = int(input())
A = inpl()
ans = [0 for i in range(N)]

for i in reversed(range(N)):
    ans[i] %= 2
    if ans[i] == A[i]:
        pass
    else:
        ans[i] = (ans[i] + 1) % 2

    if A[i] == 1:
        func(i + 1)

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

print(len(B))
if len(B) > 0:
    print(" ".join(map(str, B)))

Submission status: Wrong Answer

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

balls = list()
sums = dict()
# for i, a in enumerate(reversed(A)):
for bn in range(n, 0, -1):
    a = A[bn]
    if 2*bn > n:
        sums[bn] = a
        if a == 1:
            balls.append(str(bn))
    else:
        a2_sum = sums[2*bn]
        if a2_sum % 2 == a:
            # not
            sums[bn] = a2_sum
        else:
            # in
            sums[bn] = a2_sum + 1
            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:
n=int(input())
a=list(map(int,input().split()))
ball=[0 for i in range(n)]

for i in range(n):
    if a[n-i-1]==1:
        ball[n-i-1]=a[n-i-1]
        for j in range(int((n-i)/2)):
            if i%(j+1)==0:
                a[j]=(a[j]+1)%2

#print(ball)

ans=0
for i in range(n):
    if a[i]==1:
        ans+=1

print(ans)

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

Submission status: Wrong Answer

Solution code:
from collections import defaultdict, deque
import sys

sys.setrecursionlimit(100000)

MIN = -10 ** 9
MAX = 10 ** 9 + 7


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

    return divisors


def main():
    N = int(input())
    # A = [
    #     int(input())
    #     for _ in range(N)
    # ]
    A = [int(a) for a in input().split()]

    res_c = 0
    res1 = []
    bucket = [False] * (N + 1)

    i = N
    for Ai in reversed(A):
        i -= 1
        k = i + 1
        if k * 2 > N:
            if Ai == 1:
                res_c += 1
                res1.append(k)
                for j in range(2, int(k ** 0.5) + 1):
                    if k % j == 0:
                        bucket[j] = not bucket[j]
                        if j * j != k:
                            bucket[k // j] = not bucket[k // j]
            continue
        if k == 1:
            if res_c % 2 != Ai:
                res_c += 1
                res1.append(k)
            break

        if bucket[k] != (False if Ai == 0 else True):
            res_c += 1
            res1.append(k)
            for j in range(2, int(k ** 0.5) + 1):
                if k % j == 0:
                    bucket[j] += 1
                    if j * j != k:
                        bucket[k // j] = not bucket[k // j]
    print(res_c)
    print(*res1)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

M = 0
res = []
for n in range(1, N+1):
    ball = N // n
    if ball % 2 == a[n - 1]:
        M += 1
        res.append(str(a[n - 1]))

print(M)
print(' '.join(res))

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
x=[-1]*n
for i in range(n-1,-1,-1):
    if i>=(n+1)/2:
        x[i]=a[i]
    else:
        j=(i+1)*2
        while(j<=n): 
            a[i]=(a[i]+a[j-1])%2
            j+=i+1
        x[i]=a[i]
for i in range(n):
    if x[i]==1:
        print(i,x[i],sep='\n')

Submission status: Wrong Answer

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

ans=[]
cnt=0
B = [0 for i in range(N)]
import math
for i in range(math.floor(N/2),N):
    B[i]=A[i]
    if(A[i]==1):
        cnt+=1
        ans.append(i+1)
        
from functools import reduce
for i in range(math.floor(N/2)-1,-1,-1):
    R=[B[i*j] for j in range(2,(N//(i+1))+1)]
    r=reduce(lambda a, b: int(a==b), R)
    l=not(int(r)) if A[i]==1 else int(r)
    if l==1:
        cnt+=1
        ans.append(i+1)

print(cnt)
print(" ".join(map(str, ans)))

Submission status: Wrong Answer

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

ones = As.count(1)

if ones == 0:
    print(0)
else:
    print(ones)
    for i in range(N):
        if As[i] == 1:
            print(i+1)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [int(i) for i in input().split()]
print (sum(A))
res = []
for i in range(N):
  if A[i] == 1:
    res.append(i+1)
print (" ".join([str(item) for item in res]))

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(2*i, N, i+1):
            t += a_lst[j]
        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 (m + ans_lst[0]) % 2 == 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())
l = list(map(int, input().split()))

if l[0] == 1 and sum(l)%2 == 0:
  print('-1')
elif l[0] == 1 and sum(l)%2 == 1:
  print(sum(l))
  #print([i+1 for i, x in enumerate(l) if x != 0]) 
  print(' '.join(map(str, [i+1 for i, x in enumerate(l) if x != 0])))
elif l[0] == 0 and sum(l)%2 == 0:
  print(' '.join(map(str, [i+1 for i, x in enumerate(l) if x != 0])))
else:
  l[0] = 1
  print(' '.join(map(str, [i+1 for i, x in enumerate(l) if x != 0])))

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(" ")))
	A = input().split()
	P = getPrimeNumList(200000)

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

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

N = int(input())
a = [int(x) for x in input().split()]
ans = []
x = 0
for ind,i in enumerate(a[N//2:]):
    if(i==1):
        ans.append(ind+1+N//2)
    div = make_divisors(ind+1+N//2)
    if(i==1):
        y = 0
        for j in div:
            y += 1<<(j-1)
        x^=y
for ind,i in enumerate(a[:N//2]):
    x^=(i<<ind)
    if((x>>ind)&1==1):
        ans.append(ind+1)
print(len(ans))
if(len(ans)!=0):
    print(*ans)

Submission status: Wrong Answer

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

for i in range(2**n):
    b = [0]*n
    judge = 0
    for j in range(n):
        if ((i >> j) & 1):
            b[j] = 1

    """
    if any(sum(b[j::j+1])%2 != a[j] for j in range(n)):
        continue
    
    else:
        print(sum(b))
        for k in range(n):
            if b[k] == 1:
                print(k+1,end=" ")
        print()
        sys.exit()
        """
    for j in range(n):
        if not (sum(b[j::j+1])%2 != a[j]):
            judge = 0
            break

    if judge == 1:
        print(sum(b))
        for k in range(n):
            if b[k] == 1:
                print(k+1,end=" ")
        print()
        sys.exit()

Submission status: Wrong Answer

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

def get_index(n):
    return [i for i in range(2 * n, N + 1, n)]


def f():
    F = set()
    for n in range(N, N//2, -1):
        if A[n]:
            F.add(n)
    # print(F)

    for n in range(N//2, 0, -1):
        index = get_index(n)
        # print(n, index)
        a = sum([A[i] for i in index]) % 2
        if a != A[n]:
            F.add(n)

    return F

F = f()
print(len(F))
# if len(F) != 0:
L = list(map(str, F))
print(" ".join(L))

Submission status: Wrong Answer

Solution code:
from sys import stdin
import heapq

N = int(stdin.readline().rstrip())
a = [int(x) for x in stdin.readline().rstrip().split()]

ans = [0] * N

for i in reversed(range(N)):
    # print(i)
    # print('--')
    #print(N // (i+1))
    if N // (i+1) == 1:
        if a[i] == 0:
            ans[i] = 0
        else:
            ans[i] = 1
    else:
        if a[i] == 0:
            cnt = 0
            for j in range(N//(i+1)):
                if j == 0:
                    continue

                j = j + 1
     #           print(i)
     #           print(j)
                cnt += ans[i*j]

            if cnt % 2 == 1:
                ans[i] = 1
            else:
                ans[i] = 0

        else:
            cnt = 0
            for j in range(N//(i+1)):
                if j == 0:
                    continue

                j = j + 1
      #          print(i)
      #          print(j)
                cnt += ans[i*j]

            if cnt % 2 == 1:
                ans[i] = 0
            else:
                ans[i] = 1

M = sum(ans)
print(M)
if M != 0:
    ans_str = [str(i) for i, x in enumerate(ans) if x == 'a']
    print(' '.join(ans_str))

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)):
  tmp = 2*(i+1)-1
  if tmp <= N-1:
    B[i] = (A[tmp]+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())

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

str_ = ""
for i, a in enumerate(al):
    mod = sum(al[i::i+1]) % 2
    if a != mod:
        print(-1)
        break
    elif a == 1:
        str_ = str_ + str(i+1) + " "
else:
    print(str_)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
A_0 = A[0]
for i in range(N, 0, -1):
    ans = A[i-1]
    for o in range(1, int(i ** 0.5) + 1):
        if i%o == 0:
            A[o-1] += ans
            if o != i//o:
                A[(i//o) - 1] += ans

ans = [u//2 for u in A[:N//2]] + A[N//2:]
if ans[0] != A_0:
    print(-1)
else:
    print(ans.count(1))
    [print(q) for q, w in zip(range(1, N+1), ans) if w == 1]

Submission status: Wrong Answer

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

n = int(input())

a = [0]
for i in input().split(' '):
    a.append(int(i))

#そのままにするやつ
jissai_box = []

b = [0] * (n+1)

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

    #該当するやつ
    gaito_num = n // i
    p = sum([b[p * i] for p in range(gaito_num)])

    if p % 2 != a[i]:
        b[i] = 1
        jissai_box.append(i)

    #print([a[p * i] for p in range(gaito_num)], p % 2, a[i], p % 2 != a[i])

#for i in range(n//2, n):
#    if i == 1:
#        b.append(i)

print(len(jissai_box))

for i in jissai_box:
    print(i, end="")
print('')

Submission status: Wrong Answer

Solution code:
from collections import defaultdict, deque
import sys

sys.setrecursionlimit(100000)

MIN = -10 ** 9
MAX = 10 ** 9 + 7


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

    return divisors


def main():
    N = int(input())
    # A = [
    #     int(input())
    #     for _ in range(N)
    # ]
    A = [int(a) for a in input().split()]

    res_c = 0
    res1 = []
    bucket = [False] * (N + 1)

    i = N
    for Ai in reversed(A):
        i -= 1
        k = i + 1
        if k * 2 > N:
            if Ai == 1:
                res_c += 1
                res1.append(k)
                for j in range(2, int(k ** 0.5) + 1):
                    if k % j == 0:
                        bucket[j] = not bucket[j]
                        if j * j != k:
                            bucket[k // j] = not bucket[k // j]
            continue
        if k == 1:
            if res_c % 2 != Ai:
                res_c += 1
                res1.append(k)
            break

        if bucket[k] != (False if Ai == 0 else 1):
            res_c += 1
            res1.append(k)
            for j in range(2, int(k ** 0.5) + 1):
                if k % j == 0:
                    bucket[j] += 1
                    if j * j != k:
                        bucket[k // j] = not bucket[k // j]
    print(res_c)
    print(*res1)


if __name__ == '__main__':
    main()

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

st = int(n/2)
print(sum(a))
for ind in range(st, 0, -1):
    tmp = list(range(2*ind-1, n, ind))
    s = ls[tmp].sum()%2
    if a[ind-1] == s:
        ls[ind-1] = 0
    else:
        print(ind)

Submission status: Wrong Answer

Solution code:
import sys
import math
MAX_INT = int(10e12)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

import functools
@functools.lru_cache(maxsize=None)
def make_divisors(n):
  if n == 1:
    divisors.append(1)
    return divisors
  for i in range(int(n**0.5)+1,1,-1):
    if n % i == 0:
      divisors.append(i)
      break
  return make_divisors(n//i)

N = I()
a = IL()
cnt = [0]*N

ans = ""
M = 0
for i in range(N-1,-1,-1):
  if cnt[i]%2 == 0 and a[i] == 1 or cnt[i]%2 == 1 and a[i] == 0:
    M += 1
    ans += str(i+1) + " "
  if a[i] == 1:
    divisors = []
    l = make_divisors(i+1)
    for j in l:
      cnt[j-1] += 1

if ans == "":
  print(0)
else:
  print(M)
  print(ans[:-1])

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
ok = True
for i in range(n):
  if a[i] == 1:
    for j in range(int(n/(i+1))):
      if a[(i+1)*j+i] == 1:
        ok = False
    else:
      continue
    break
if a.count(1) > n:
  ok = False
if ok == False:
  print(-1)
  exit()

if a.count(1) == 0:
  print("0")
  exit()
else:
  print(a.count(1))
  print(' '.joint(str(a)))

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
f=0
for i in range(1,n+1):
    _a=a[i-1::i]
    s=sum(_a)%2
    if s!=a[i-1]:
        f=1
if f:
    print(-1)
else:
    s=sum(a)
    if s:
        print(s)
        for _a in a:
            if _a:
                print(1,end="")
        print('')
    else:
        print(0)

Submission status: Wrong Answer

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

ans=[]
for i in range(n//2,n):
  if li[i]==1:
    ans.append(i+1)
ans.reverse()
for i in range(n//2,0,-1):
  count=0
  for j in ans:
    if j%i==0:
      count+=1
  count+=li[i]
  if count%2==1:
    ans.append(i)
ans.reverse()
print(len(ans))
L=[str(a) for a in ans]
L=" ".join(L)
if len(L)!=0:
  print(L)

Submission status: Wrong Answer

Solution code:
N = int(input())
l = list(map(int,input().split(' ')))
mid = N // 2
MAP = [0]*N
ans_l = []
for i in range(N-1,mid-1,-1):
    k = l[i]
    MAP[i] = k
    if k==1:
        ans_l.append(str(i+1))
flag = False
for i in range(mid,0,-1):
    s = N // i + 1
    t = 0
    for j in range(2,s):
        t += MAP[i*j-1]
    if t%2==0:
        if l[i-1]%2==1:
            ans_l.append(str(i))
            MAP[i-1] += 1
    else:
        if l[i-1]%2==0:
            ans_l.append(str(i))
            MAP[i-1] += 1

leng = len(ans_l)
print(leng)
if leng==0:
    print(0)
else:
    print(" ".join(ans_l))

Submission status: Wrong Answer

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

B = []
for _ in range(N):
    if sum(A[_::_+1]) % 2 == A[_]:
        if A[_] == 1:
            B.append(_+1)
    else:
        print(-1)
        quit()
print(len(B))
for _ in B:
    print(_)

Submission status: Wrong Answer

Solution code:
n = input()
li = list(map(int,input().split()))
flag = True
count = 0
one = []

for i in range(len(li)) :
    if(li[i] == 1):
        count += 1
        one.append(i + 1)
    j = i
    sum = 0
    while(j < len(li)):
        sum += li[j]
        j += (i+1)
    sum2 = sum % 2
    if(li[i] != sum2):
        flag = False
        break

if(flag == False):
    print(-1)
else:
    print(count)
    if(count != 0):
        print(*one)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
import math

def add_ball(idx):
    b_list[idx] = (b_list[idx]+1)%2
    if idx > 0:
        b_list[0] = (b_list[0]+1)%2
        idx += 1 # 0-origin to 1-origin
        for j in range(2, int(math.sqrt(idx))+1):
            if idx%j == 0:
                k = int(idx/j)
                if j == k:
                    b_list[j] = (b_list[j]+1)%2
                    break
                elif j < k:
                    b_list[j] = (b_list[j]+1)%2
                    b_list[k] = (b_list[k]+1)%2
                else:
                    break


if __name__ == "__main__":
    input = sys.stdin.readline

    n = int(input())
    a_list = list(map(int, input().split()))
    b_list = [0] * n
    for i, a in enumerate(a_list[::-1]):
        if a != b_list[-i-1]:
            add_ball(n-i-1)
    ball_sum = sum(b_list)
    ball_list = [i+1 for i, b in enumerate(b_list) if b == 1]
    print(ball_sum)
    if ball_sum > 0:
        print(' '.join(map(str, ball_list)))

Submission status: Wrong Answer

Solution code:
n = int(input())
N = input()
N = N.split(" ")
Ni = []
cnt=0
A = []
for i in N:
    cnt = cnt + 1
    Ni.append(int(i))
    if int(i) == 1:
        A.append(cnt)
flg = True
for i in range(len(Ni)):
    if not Ni[i] == sum(Ni[i::i+1]):
        flg = False
if flg:
    if len(A)>0:
        string = str(A[0])
        if len(A) > 1:
            for j in A[1:]:
                print(string)
                string = string + " "
                string = string + str(j)
        print(string)
    elif len(A)==0:
        print(0)
else:
    print(-1)

Submission status: Wrong Answer

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

def get_index(n):
    return [i for i in range(2 * n, N + 1, n)]


def f():
    F = set()
    for n in range(N, N//2, -1):
        if A[n]:
            F.add(n)
    # print(F)

    for n in range(N//2, 1, -1):
        index = get_index(n)
        # print(n, index)
        a = sum([A[i] for i in index]) % 2
        if a != A[n]:
            F.add(n)

    if len(F) % 2 != A[1]:
        F.add(1)

    return F

F = f()
print(len(F))
# if len(F) != 0:
L = list(map(str, F))
print(" ".join(L))

Submission status: Wrong Answer

Solution code:
n = int(input())
figure = list(map(int, input().split()))
error = 0#０だと正常

for x in range(n):
  a = 0
  for i in range(x,n,x+1):
    if figure[i] == 1:
      a +=1
#  print("a",a)
  if figure[x] != (a%2):
    error += 1
    print("-1")
    break
if error == 0:
  data = list(map(lambda x:x+1, figure))
  if not data:
    print("0")
  else:
    print(*data)

Submission status: Wrong Answer

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

n = int(input())
num_list = [ int(v) for v in input().split() ]
ans_list = [ 0 ] * n

for i in range(n-1,-1,-1):
    print(i)
    print(num_list[i::i+1])
    if sum(num_list[i::i+1]) % 2 == 0:
        ans_list[i] = 0
    else:
        ans_list[i] = 1

for i in range(n):
    if ans_list[i] == 1:
        print(i+1)

Submission status: Wrong Answer

Solution code:
def main():
    n = int(input())
    a_s = list(map(int, input().split(' ')))
    results = []
    for i, a in enumerate(reversed(a_s)):
        idx = (n-1) - i
        if sum(a_s[idx::(idx+1)]) % 2 == a and a == 1:
            results.append(str(idx+1))
    print(len(results))
    if results:
        print(' '.join(results))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N=int(input())
S=set()
NUM=[]
for i in range(1,N+1):
    S.add(i)
    NUM.append(i)
A=list(map(int,input().split()))
flag = False
for i in reversed(range(1, N+1)):
    for j in range(1, N+1):
        tmp = i * j
        if tmp > N:
            break
        if tmp not in S:
            break
        S.discard(tmp)
        if A[i-1] == 1:
            print(tmp)
            flag = True
if not flag:
    print(0)

Submission status: Wrong Answer

Solution code:
import numpy as np

def main():
    n = int(input())
    a = np.zeros([n], dtype=int)
    box = np.array(range(1,n+1))
    a = list(map(int, input().split(" ")))
    b = np.zeros_like(a)

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

    for i in box[:n//2][::-1]:
        t = np.array(range(i, n+1, i))
        if np.sum(a[i-1::i]) != a[i-1]:
            b[i-1] = 1

    ball = np.where(b==1)[0]
    print(len(ball))
    for i in ball:
        print(box[i], end=" ")
        

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import math
import copy
import numpy as np

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

i = maxnum
num_list = []
output_list = []

while i > 0:
  if a[i-1] == 1:
    if len(num_list) == 0:
      num_list.append(i)
    else:
      count = 0
      for x in num_list:
        if x % i == 0:
          count += 1
        
        if count % 2 == 0:
          num_list.append(i)
  else:
    if len(num_list) == 0:
      pass
    else:
      count = 0
      for x in num_list:
        if x % i == 0:
          count += 1
        
        if count % 2 == 1:
          num_list.append(i)
  i -= 1
  
print(len(num_list))
print(' '.join([str(n) for n in num_list]))

Submission status: Wrong Answer

Solution code:
import math

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

#print(As)
anss = [-1 for _ in range(N)]
sums = [0 for _ in range(N)]
for i in reversed(range(len(As))):
	num = math.floor(N/(i+1))
	rem = num % 2
	if num == 1:
		if As[i] == 0:
			anss[i] = 0
			if i+1 <= N-1:
				sums[i] = (sums[i+1] + anss[i]) % 2
		else:
			anss[i] = 1
			if i+1 <= N-1:
				sums[i] = (sums[i+1] + anss[i]) % 2
	else:
		if i+1 <= N-1:
			if sums[i+1] + As[i] == 1:
				anss[i] = 1
			else:
				anss[i] = 0
	
	#print(i,As[i],num,rem,anss,sums)
	
#print(anss)
#print(sums)

print(anss.count(1))
for i in range(len(anss)):
	if anss[i] == 1:
		print(str(i+1)+" ",end="")