Problem:


Score : 400 points

Problem Statement

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

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

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

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

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

Constraints

All values in input are integers.

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

a_i is 0 or 1.

Input

Input is given from Standard Input in the following format:

N
a_1 a_2 ... a_N

Output

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

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

M
b_1 b_2 ... b_M

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

Sample Input 1

3
1 0 0

Sample Output 1

1
1

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

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

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

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

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

Sample Input 2

5
0 0 0 0 0

Sample Output 2

0

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



Sample input:
3
1 0 0


Sample output:
1
1

Submission status: Wrong Answer

Solution code:
import math
N = int(input())
ax = list(map(int,input().split()))

boxin = []
bx = [0 for _ in range(N+1)]
for cnt in range(N, 0, -1):
    a = ax[cnt-1]
    j = 2
    tmp = 0
    while 1:
        if cnt * j < N:
            if bx[cnt * j] != 0:
                tmp += 1
        else:
            break
        j += 1
    
    if tmp % 2 != a:
        boxin.append(cnt)

box = len(boxin)
print(box)
if box != 0:
    boxin.reverse()
    print(' '.join(map(str, boxin)))

Submission status: Wrong Answer

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

ball_list = [0] * (N + 1)
for n in reversed(range(1, N + 1)):
    mod = 0
    for i in range(n, N + 1, n):
        mod ^= ball_list[i]
    if mod != a_list[n - 1]:
        ball_list[n] = 1

num = sum(ball_list)
print(num)

if num > 0:
    for b in ball_list:
        if b == 1:
            print(b)

Submission status: Wrong Answer

Solution code:
import logging

logging.basicConfig(level=logging.INFO, format="%(message)s")
#logging.disable(logging.CRITICAL)

def main():
    N = int(input())
    a_ = list(map(int, input().split()))
    box = [0 for _ in range(N)]

    logging.info("Hello!")

    for i in range(N):
        box_num = N - i

        sum = 0
        for j in range((N // (box_num)) - 1):
            sum += a_[(box_num) * (j + 2) - 1]
            
        box[box_num - 1] = abs(a_[box_num - 1] + (sum % 2))

    logging.info(box)

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

    print(answer)
    
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import math
N = int(input())
ax = list(map(int,input().split()))

boxin = []
bx = [0 for _ in range(N+1)]
for cnt in range(N, 0, -1):
    a = ax[cnt-1]
    j = 2
    tmp = 0
    while 1:
        if cnt * j < N:
            if bx[cnt] != 0:
                tmp += 1
        else:
            break
        j += 1
    
    if tmp % 2 != a:
        boxin.append(cnt)

box = len(boxin)
print(box)
if box != 0:
    boxin.reverse()
    print(' '.join(map(str, boxin)))

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[i: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())
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):
    print("x",x,"i",i)
    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:
N = int(input())
a = [int(i) for i in input().split()]
answer = [0]*N
dp = [0]*N

for i in range(N-1, -1, -1):
  if i >= N//2 and a[i] == 1:
    answer[i] = 1
    dp[i] = 1

  if i < N//2:
    if (a[i] == 1 and dp[i*2+1]%2 == 0) or (a[i] == 0 and dp[i*2+1]%2 == 1):
      answer[i] = 1
      dp[i] += dp[i*2+1]

print(len([i for i in answer  if i == 1]))
not_empty_boxes = [str(index+1) for index, value in enumerate(answer) if value == 1]
if len(not_empty_boxes) > 0:
  print(' '.join(not_empty_boxes))

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)):
    if A[i] == 1:
        func(i + 1)

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

# print(ans)
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:
import math
N=int(input())
a=list(map(int, input().split()))

H=math.floor(N / 2) 
B=a[H:N]

for i in range(H-1,-1,-1):
    s = 0
    j = i
    while j < N:
        s+=a[j]
        j+=(i+1)
    B.insert(0, s % 2)

ans = [i + 1 for i, x in enumerate(B) if x == 1]
l = len(ans)
print(l)
if (l > 0):
    print(*ans)

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(N,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()))
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]
print(sum(x))
if sum(x)!=0:
    for i in range(n):
        print(x[i],end=' ')

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
''' 
------------------------
author : iiou16
------------------------
'''

def main():
    N = int(input())
    A = list(map(int, input().split()))

    B = [0] * N
    for i in reversed(range(N)):
        mm = N // (i + 1)
        if mm == 1:
            B[i] = A[i]
        elif i > 1:
            for m in range(mm)[1:]:
                # if i == 1:
                #     print(A[i], B[i * (m + 1) + 1])
                #     break
                B[i] = A[i] ^ B[i * (m + 1) + 1]
        else:
            if sum(B) % 2  == A[0]:
                B[0] = 0
            else:
                B[0] = 1
            # print(i, mm, B[i])
    print(sum(B))
    out = []
    
    if sum(B) != 0:
        for i in range(len(B)):
            if B[i] == 1:
                out.append(i + 1)
        out = list(map(str, out))
        print(" ".join(out))

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
INF = float("inf")

MOD = 2  # type: int


import math
import collections


def factorial(n):
    # 試し割りによる素因数分解
    prime_count = collections.Counter()

    for i in range(2, int(math.sqrt(n)) + 2):
        while n % i == 0:
            n /= i
            prime_count[i] += 1
    if n > 1:
        prime_count[int(n)] += 1

    return prime_count


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


def solve(N: int, a: "List[int]"):
    b = [0]*N
    for i in range(N-1, -1, -1):
        if b[i] % MOD != a[i]:
            b[i] = 1-b[i] % MOD
        if b[i] % MOD == 1:
            for d in make_divisors(i)[: -1]:
                b[d] += 1

    c = [i+1 for i, val in enumerate(b) if val % 2 > 0]
    print(len(c))
    if len(c) != 0:
        print(*c, sep=" ")
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, a)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

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

for i in reversed(range(N)):
    if A[i] != B[i]:
        put.append(i+1)
        # iを素因数分解して、約数に1をxorしていく
        tmp = 1
        n = i+1
        while tmp*tmp <= n:
            if n % tmp == 0:
                B[tmp-1] ^= 1
            tmp += 1


if len(put) > 0:
    print(len(put))
    print(*put)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
n= int(input())
A = list(map(int, input().split()))
B = [0]*n
B_sum = [0]*n
A_sum = sum(B)
count = 0
ans = False

for i in range(n):

    j = 1
    while (n-i)*j <= n:
        B_sum[n-i-1] += B[(n-i-1)*j]
        j += 1
    if B_sum[n-i-1] % 2 != A[n-i-1]:
        B[n-i-1] = 1
        count += 1
print(count)
for i in range(n):
    
    if B[i]==1:
        print(i+1)

Submission status: Wrong Answer

Solution code:
import fractions
from collections import deque
import numbers as np
import math


def isPrime(x):
    if x < 2:
        return True
    elif x == 2:
        True
    elif x % 2 == 0:
        False

    for i in range(1, int(math.sqrt(x))+1):
        if x % i == 0:
            return False

    return True


def main():
    N = int(input())
    a = list(map(int, input().split()))
    b = a[:]
    prime_list = deque()

    for i in range(1, N+1):
        if isPrime(i):
            prime_list.appendleft(i)

    for i in reversed(range(N//2 - 1)):
        a_t = a[i]
        t_sum = 0
        for prime in prime_list:
            ids = prime * (i+1)
            if N >= ids:
                t_sum += b[ids-1]
        guuki = t_sum % 2
        if a_t == 1 and guuki == 0:
            b[i] = 1
        elif a_t == 0 and guuki == 0:
            b[i] = 0
        elif a_t == 1 and guuki == 1:
            b[i] = 0
        elif a_t == 0 and guuki == 1:
            b[i] = 1
    cnt = 0
    ret = deque()
    for i in range(N):
        if b[i] > 0:
            cnt += 1
            ret.appendleft(i + 1)
    print(cnt)
    for i in ret:
        print(i, end=' ')


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import logging

logging.basicConfig(level=logging.INFO, format="%(message)s")
#logging.disable(logging.CRITICAL)

def main():
    N = int(input())
    a_ = list(map(int, input().split()))
    box = [0 for _ in range(N)]

    logging.info("Hello!")

    half_N = N // 2
    for i in range(N - half_N):
        box[N - i - 1] = a_[N - i - 1]

    for i in range(half_N):
        box_num = half_N - i

        sum = 0
        for j in range((N // (box_num)) - 1):
            sum += a_[(box_num) * (j + 2) - 1]

        box[box_num - 1] = (a_[box_num - 1] + (sum % 2)) % 2

    logging.info(box)

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

    print(answer)
    
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import math
def func1(lst, value):
    return [i+1 for i, x in enumerate(lst) if x == value]
N = int(input())
a = list(map(int,input().split()))

b = [0] * N
half = math.ceil(N/2)
summ = 0
for i in reversed(range(N)):
    # print(i)
    # if i >= half-1:
    #     b[i] = a[i]
    # else:
    x = N//(i+1)
    for j in range(1,x):
        summ += a[(i+1)*(j+1)-1]
    judge=summ%2
    if (judge==0 and a[i]==0) or (judge==1 and a[i]==1):
        b[i] = 0
    else:
        b[i] = 1
    summ = 0
    judge = 0
print(sum(b))
if sum(b) != 0:
    ans = func1(b,1)
    # print(ans)
    if len(ans)>1:
        ans = map(str,ans)
        print(" ".join(ans))
    else:
        print(ans.pop())

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[i:N:i+1])-listA[i])%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_list = list(map(int,input().split()))
b_list = []

for i in range(n):
    if a_list[-i-1] == 1:
        count = 0
        for j in b_list:
            if j%i == 0:
                count += 1
        if count%2 == 0:
            b_list.append(n-i)
            
        
b_list.reverse()
x = len(b_list)
print(x)
if x != 0:
    print(*b_list)

Submission status: Wrong Answer

Solution code:
n= int(input())
A = list(map(int, input().split()))
B = [0]*n
B_sum = [0]*n
A_sum = sum(B)
count = 0
ans = False

for i in range(n):

    j = 1
    while (n-i)*j <= n:
        B_sum[n-i-1] += B[(n-i-1)*j]
        j += 1
    if B_sum[n-i-1] % 2 != A[n-i-1]:
        B[n-i-1] = 1
        count += 1

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

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-1] = (b_list[j-1]+1)%2
                    break
                elif j < k:
                    b_list[j-1] = (b_list[j-1]+1)%2
                    b_list[k-1] = (b_list[k-1]+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:
# -*- 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
    pp = sum([b[p * i] for p in range(gaito_num)])

    if pp % 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:
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
b=[]
for i in range(n):
    if a[i]==1:
        ans+=1
        b.append(i)

print(ans)
print(*b)

Submission status: Wrong Answer

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

for i in range(int(N/2),N):
  j = N- i -1
  c[j] = a[j] * a[j*2]
  if c[j] > 1:
    c[j] = 0

M = c.count(1)
b = []

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

print(M)

for i in range(M):
  print(b[i]," ")

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, 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:
n= int(input())
A = list(map(int, input().split()))
B = [0]*n
B_sum = [0]*n
A_sum = sum(B)
count = 0
ans = False

for i in range(n):

    j = 1
    while (n-i)*j <= n:
        B_sum[n-i-1] += B[(n-i-1)*j]
        j += 1
    if B_sum[n-i-1] % 2 != A[n-i-1]:
        B[n-i-1] = 1
        count += 1

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

Submission status: Wrong Answer

Solution code:
import sys
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 = list(map(int, input().split()))

ball_list = [0] * (N + 1)
reverse_range = list(reversed(range(1, N + 1)))
for n in reversed(range(1, N + 1)):
    mod = 0
    for i in reverse_range[::n]:
        mod ^= ball_list[i]
    if mod != a_list[n - 1]:
        ball_list[n] = 1

num = sum(ball_list)
print(num)

if num > 0:
    for b in ball_list:
        if b == 1:
            print(b)

Submission status: Wrong Answer

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

X = [0] * (N+1)
for i in range(N,0,-1):
    a = A[i]
    if i*2 > N:
        X[i] = a
    else:
        cur = X[i*2]
        b = 0
        if cur==0 and a==0:
            X[i] = 0
        elif cur==0 and a==1:
            X[i] = 1
        elif cur==1 and a==0:
            X[i] = 1
        else:
            X[i] = 0

Y = []
for i in range(1,N+1):
    if X[i] == 1:
        Y.append(str(i))

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

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
import numpy as np

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

ms = np.arange(1, M + 1)
multiple = dict()
for i in range(0, M):
    multiple[i] = np.where(np.mod(ms, i + 1) == 0)

prime = np.zeros(M, dtype=np.int)

ans = list()
for i in range(M - 1, -1, -1):
    p = prime[multiple[i]]
    if sum(prime[multiple[i]]) % 2 < a[i]:
        prime[i] = 1

    if sum(prime[multiple[i]]) % 2 != a[i]:
        print('-1')
        exit()

    
print(' '.join(map(str, [ i for i in prime[np.where(prime == 1)]])))

Submission status: Wrong Answer

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

for n in range(N):
  i = N-n
  # print(i)
  if A[i-1] == 1:
    BB = B[::i]
    if (sum(BB))%2 == 0:
      B[i] = 1
    else:
      B[i] = 0
    # print(B)
    if B[i] == 1:
      x.append(str(i))
  else:
    B[i] = 0
  
if len(x) == 0:
  print(0)
else:
  print(len(x))
  print(' '.join(x))

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,0,-1):
    for j in range(2,N):
        if j*(i+1) <= N:
            if box[j*(i+1)-1]==1:
                sum+=1
        else:
            break
    if a_list[i] == 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:
n = int(input())
a = input()
al = list(map(int, a.split()))
ans = [al.index(i)+1 for i in al if i == 1]


if set(al) == 0:
    print(0)
else:
    if sum(al)%2 != al[0]:
        print(-1)
    else:
        for i in range(2,n):
            if sum(al[i::i])%2 != al[i]:
                print(-1)
                break
        else:
            print(sum(al))
            print(ans)

Submission status: Wrong Answer

Solution code:
n= int(input())
A = list(map(int, input().split()))
B = [0]*n
B_sum = [0]*n
A_sum = sum(B)

ans = False

for i in range(n):

    j = 1
    while (n-i)*j <= n:
        B_sum[n-i-1] += B[(n-i-1)*j]
        j += 1
    if B_sum[n-i-1] % 2 != A[n-i-1]:
        B[n-i-1] = 1
print(1)
for i in range(n):

    if B[i]==1:
        print(i+1)

Submission status: Wrong Answer

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

X = [0] * (N+1)
for i in range(N,0,-1):
    a = A[i]
    if i*2 > N:
        X[i] = a
    else:
        cur = X[i*2]
        b = 0
        if cur==0 and a==0:
            X[i] = 0
        elif cur==0 and a==1:
            X[i] = 1
        elif cur==1 and a==0:
            X[i] = 1
        else:
            X[i] = 0

Y = []
for i in range(1,N+1):
    if X[i] == 1:
        Y.append(str(i))

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

Submission status: Wrong Answer

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

from math import ceil

n = int(input())
a = list(map(int,input().split()))
b = ['0'] * (n+1)
c = ceil((n+1)/2)-1
for i in range(c, n):
    if a[i] == 1:
        b[i+1] = '1'
    else:
        b[i+1] = '0'
    
for i in reversed(range(0, c)):
    d = n // (i+1)
    cn = 0
    for j in range(1, d+1, i+1):
        if b[j] == '1':
            cn += 1
    if cn % 2 == a[i]:
        b[i+1] = '0'
    else:
        b[i+1] = '1'
print(b.count('1'))
del b[0]
ee = []
for i,v in enumerate(b):
    if v == '1':
        ee.append(str(i+1))
print(' '.join(ee))

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[0:len(out)-1])
else:
    print("-1")

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
INF = float("inf")

MOD = 2  # type: int


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


def solve(N: int, a: "List[int]"):
    b = [0]*N
    for i in range(N-1, -1, -1):
        if b[i] % MOD != a[i]:
            b[i] = 1-b[i] % MOD
        if b[i] % MOD == 1:
            # print(make_divisors(i))
            for d in make_divisors(i)[: -1]:
                b[d] += 1
    # for i in range(N//2-1, -1, -1):
    #     if a[i] != b[i] % 2:
    #         b[i] += 1
    # b[0] = a[0]-b[0]
    # print(b)

    c = [i+1 for i, val in enumerate(b) if val % 2 > 0]
    print(len(c))
    if len(c) != 0:
        print(*c, sep=" ")
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, a)


if __name__ == '__main__':
    main()

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]
  print(listN)
  print(listB)
  if len(listN)==1 and listA[i]==1:
    listB[i]=1
  elif len(listN)>1 and sum(listN)%2!=(sum(listB[i:N:i+1])-listA[i])%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())
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:
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+1) for i, x in enumerate(ans) if x == 1]
    print(' '.join(ans_str))

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]
print(m)
for i in range(n):
  if b[i]==1:
    print(i)

Submission status: Wrong Answer

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

B = [1] * N

for i in range(N):
    tmp = i + 1
    while tmp < N:
        B[tmp] += 1
        tmp += (i + 1)
B = [A[i] if B[i] > 1 else B[i] for i in range(N)]

print(A)
print(B)

if 1 in B:
    print(B.count(1))
    for i in range(len(B)):
        if B[i] == 1:
            print(i)
else:
    print(0)

Submission status: Wrong Answer

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


c = []
for value, index in enumerate(a):
    if value == 1:
        c.append(index)

d = []
for i in range(len(c)-1, 0, -1):
    count = 0
    for item in d:
        if item % i == 0:
            d.append(i)

if len(d) == 0:
    print("-1")

M = sum(d)
print(M)
ans = ' '.join(map(str, d))
print(ans)

Submission status: Wrong Answer

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

for n in range(N):
  i = N-n
  # print(i)
  if A[i-1] == 1:
    BB = B[::i]
    if (sum(BB))%2 == 0:
      B[i] = 1
    else:
      B[i] = 0
    # print(B)
    if B[i] == 1:
      x.append(str(i))
  else:
    B[i] = 0

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
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:
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]
flag=0
for i in range(n):
    if x[i]==1:
        print(i+1,x[i],sep='\n')
        flag=1
if flag==0:
    print(0)

Submission status: Wrong Answer

Solution code:

n=int(input())
m=0
    
    
    
a=list(map(int,input().split()))
ans=[0 for i in range(n)]
   

x=0
for i in reversed(range(1,n)):
        if(i*2>=n):
                ans[i]==a[i]
                if(a[i]==1):
                        m+=1
        
        elif(i*2<n):
                h=2
                while(i*h<n):
                        e=i*h
                        x+=ans[e]
                        h+=1
            
                if(x%2==a[i]):
                        x+=1
                        m+=1
                
                ans[i]=x
                x=0
        
    



print(m)
for i in range(n):
        print(ans[i] if ans[i]==1 else "",end="")
print("")

Submission status: Wrong Answer

Solution code:
import sys

def main():
    _ = int(input())
    A = list(map(int,input().split()))

    M = set()
    lenA = len(A)
    for i in range(len(A))[::-1]:
        if i > lenA/2:
            if A[i] == 1:
                M.add(i+1)
        else:
            curr = i+1
            bai = set()
            bai.add(curr)
            while curr >= lenA:
                curr += curr
                bai.add(curr)
            num = len(M&bai) % 2
            if A[i] != num:
                M.add(i+1)
    
    print(len(M))
    if len(M) > 0:
        print(*M)

if __name__=='__main__':
    main()

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
b=[]
for i in range(n):
    if a[i]==1:
        ans+=1
        b.append(i)

print(ans)
print(b)