Problem:


Score : 400 points

Problem Statement

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

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

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

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

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

Constraints

All values in input are integers.

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

a_i is 0 or 1.

Input

Input is given from Standard Input in the following format:

N
a_1 a_2 ... a_N

Output

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

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

M
b_1 b_2 ... b_M

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

Sample Input 1

3
1 0 0

Sample Output 1

1
1

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

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

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

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

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

Sample Input 2

5
0 0 0 0 0

Sample Output 2

0

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



Sample input:
3
1 0 0


Sample output:
1
1

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, d=DVSR): return pow(x, d - 2, d)
def DIV(x, y, d=DVSR): return (x * INV(y, d)) % d
def LI(): return [int(x) for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()
def II(): return int(input())

N=II()
INL=LI()
RES=[0]*(N+1)
cnt = 0
for i in range(N, 0, -1):
    pt = 2*i
    sm = 0
    while pt <= N:
        sm += RES[pt]
        pt += i
    if not sm & 1 and INL[i-1]:
        cnt += 1
        RES[i] = 1

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

Submission status: Wrong Answer

Solution code:
import sys,math,copy
input = sys.stdin.readline

N=int(input().strip())
An=[int(x) for x in input().strip().split()]
Bn=[-1 for _ in range(N)]
Sum=0
for i in range(N-1,-1,-1):
    temp=0
    c=2
    index=(i+1)*c
    while index <= N:
        temp=temp^An[index-1]
        c+=1
        index+=(i+1)

    ball=An[i] ^ temp
    Sum+=ball
    Bn[i]= str(ball)


print(Sum)
if Sum!=0:
    print(' '.join(Bn))

Submission status: Wrong Answer

Solution code:
N = int(input())
a = [int(x) for x in input().split()]
isball = [0]*N
ball_list = []
oddeven = 0
for i in reversed(range(1, N)):
    ball_sum = 0
    for j in range(N // i):
        ball_sum += isball[j * i]
    if ball_sum % 2 != a[i]:
        ball_list.append(i + 1)
        isball[i] = 1
        oddeven += 1

if oddeven % 2 != a[0]:
    ball_list.append(1)

print(len(ball_list))
print(*ball_list)

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()))
box = [0]*(N+1)
put = [0]*N

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

ans = []
print(len(ans))
if len(ans) > 0:
    for i in range(N):
        if put[i] == 1:
            ans.append(i+1)
    print(*ans)

Submission status: Wrong Answer

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

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

cnt = a.count(1)
if cnt <= n:
    print(cnt)
    ans = []
    for i in range(n):
        if a[i] == 1:
            ans.append(i+1)
    if 0 != len(ans):
         print(" ".join(map(str,ans)))

else:
    print(-1)

Submission status: Wrong Answer

Solution code:
"""
n = int(input())
dat = list(map(int, input().split()))
res = [0] * n
for i in range(n, 0, -1):
    # i-1で参照すること
    print(i)
    t = 0
    for j in range(n // i):
        t += dat[ (j * i) -1]
    print("i[{0}]:  t = {1}".format(i, t))
"""
n = int(input())
dat = list(map(int, input().split()))
c = 0
#print(dat)
for i in range(n):
    if dat[i] == 1:
        c += 1

res = []
resc = c
for i in range(n):
    if c == 0:
        break
    if dat[i] == 1:
        c -= 1
        res.append("1")
    else:
        res.append("0")

print(resc)
if resc !=0:
    print(" ".join(res))

Submission status: Wrong Answer

Solution code:
import copy
n = int(input())
a = list(map(int,input().split()))
b = []
for i in range(n):
	b.append(0)
for i in reversed(range(1,n+1)):
	j = copy.deepcopy(i)
	j -= 1
	sums = 0
	for k in range(int(n/i)):
		s = k*i
		sums += b[s]
	if(sums == a[j]):
		b[j] = 0
	else:
		b[k] = 1

ans = []
anstext = ''
for i in reversed(b):
	if(i!=0):
		ans.append(i)
		anstext = anstext + str(i) + ' '
print(len(ans))
print(anstext[:-2])

Submission status: Wrong Answer

Solution code:
import math

n = int(input())

ans = [0] * n

def yakusuu(num):
    ret = []    
    for i in range(math.ceil(math.sqrt(num)+1)+1):
        if i != 0 and num % i == 0:
            ret.append(i)
    others = []
    for i in ret:
        others.append(int(num / i))
        
    ret.extend(others)
    return set(ret)

#print("{}".format(yakusuu(4)))

an = list(map(int, input().split()))
for i in range(n):
    a = an[i]
    if a == 1:
#        print("{}".format(yakusuu(i+1)))
        for divisor in yakusuu(i+1):
            ans[divisor-1] = ans [divisor-1] + 1


ans = list(map(lambda x: x%2,ans))
print("{}".format(ans.count(1)))

for i in range(n):
    if ans[i] == 1:
        print("{}".format(i+1))

Submission status: Wrong Answer

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

hako = [0]*(N+1)

for i in range(N, 0, -1):
    cnt = 0
    j = i
    while j <= N:
        cnt += hako[j]
        j += j
    
    if cnt%2 != A[i]:
        hako[i] = 1

print(hako.count(1))
s = ""
for i, x in enumerate(hako):
    if x == 1:
        s += str(i) + " "

print(s)

Submission status: Wrong Answer

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

M = 0
for i in range(1, N + 1) :
    ret = 0
    for j in range(i, N + 1, i) :
        ret += a[j-1]
    if ret % 2 == 1 :
        M += 1
print(M)
if M != 0 :
    print(' '.join([str(1) for _ in range(M)]))

Submission status: Wrong Answer

Solution code:
N = int(input())
aList = list(map(int, input().split()))
ansList = [0 for x in range(N+1)]
M = 0
answer = '0'

def method(n):
    List = list()
    for x in range(1,n+1):
        if n % x == 0:
            List.append(x)
    return List

for x in range(N):
    if aList[x] == 0:
        continue
    else:
        number = method(x+1)
        for x in number:
            ansList[x] += 1
        
for x in range(N+1):
    if ansList[x] % 2 == 1:
        M += 1
        if answer == '0':
            answer = str(x)
        else:
            answer += ' ' + str(x)

print(M)
if answer != '0':
    print(answer)

Submission status: Wrong Answer

Solution code:

N = int(input())

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


for i in range(N):

    cnt = 1
    summ = 0
    flag = True

    while (i + 1) * cnt <= N:

        summ += a[(i + 1) * cnt -1]
        cnt += 1

    if summ % 2 != a[i]:
        flag = False

if flag :
    

    #print (lis)

    print (sum(a))

    ans = ""

    for i in range(len(a)):
        if a[i] == 1:
            ans += str(i+1) + " "

    print (ans)

else:
    print (-1)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
ans = [0] * n
for i in range(n, 0, -1):
    k = 0
    j = 2
    l = j * i
    while l <= n:
        if ans[l-1] == 1:
            k += 1
        j += 1
        l = j * i
    if k % 2 != a[i-1]:
        ans[i-1] = 1

m = sum(ans)
s = ""
for i in range(n):
    if ans[i] == 1 and s == "":
        s += str(ans[i])
    elif ans[i] == 1:
        s += " "+str(ans[i])

if m == 0:
    print(m)
else:
    print(m)
    print(s)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
box = {}
ans = ""
count = 0

for i in range(N, 0, -1):
    box[i] = 0
    a = 0
    for j in range(N//i):
        a += box[(j+1)*i]
    if a % 2 != A[i-1]:
        box[i] = 1
        count+=1
        if ans:
            ans += " " + str(i)
        else:
            ans = str(i)

print(count)
if ans:
    print(ans)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
import sys
import copy


def input():
    return sys.stdin.readline()[:-1]


def main():
    n = int(input())
    a = [int(i) for i in input().split()]
    b = copy.copy(a)
    middle = len(a)//2-1
    ans = []

    for i in range(middle, -1, -1):
        s = 0
        for j in range(i, n, i+1):
            s += a[j]
        b[i] = s % 2

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

    m = len(ans)
    print(m)
    if m > 0:
        print(*ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

Solution code:
import copy
n = int(input())
a = list(map(int,input().split()))
b = []
for i in range(n):
	b.append(0)
for i in reversed(range(1,n+1)):
	j = copy.deepcopy(i)
	j -= 1
	sums = 0
	for k in range(int(n/i)):
		s = k*i
		sums += b[s]
	if(sums == a[j]):
		b[j] = 0
	else:
		b[k] = 1

ans = []
anstext = ''
for i in reversed(b):
	if(i!=0):
		ans.append(i)
		anstext = anstext + str(i) + ' '
print(len(ans))
if(len(anstext)!=0):
	print(anstext[:-2])

Submission status: Wrong Answer

Solution code:
import numpy as np
N = int(input())
a = np.array(list(map(int, input().split())), dtype='i')
b = np.zeros_like(a, dtype='i')
b[N//2:] = a[N//2:]
for i in reversed(range(N//2)):
    j = i+1
    b[i] = (np.sum(a[np.arange(2, N//j+1)*j-1]) + a[i])%2
print(np.sum(b))
w = np.where(b==1)[0]+1
print(' '.join(list(map(str, w))))

Submission status: Wrong Answer

Solution code:
import sys,collections as cl,bisect as bs,math
sys.setrecursionlimit(100000)
Max = sys.maxsize
def l(): #intのlist
	return list(map(int,input().split()))
def m(): #複数文字
	return map(int,input().split())
def onem(): #Nとかの取得
	return int(input())
def s(x): #圧縮
	a = []
	aa = x[0]
	su = 1
	for i in range(len(x)-1):
		if aa == x[i+1]:
			a.append([aa,su])
			aa = x[i+1]
			su = 1
		else:
			su += 1
	a.append([aa,su])
	return a
def jo(x): #listをスペースごとに分ける
	return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
	return max(map(max,x))

n = onem()

a = l()
k = 0
for i in range(n):
	if a[-(i+1)] == 1:
		k = n - i
		break
if k == 0:
	print(0)
	exit()

m = [0 for i in range(k+1)]
al = 0
for i in range(k,0,-1):
	co = 0
	if k // i < 2:
		m[i] = a[i-1]
		al += a[i-1]
	else:
		if i != 1:
			for j in range(1,k // i):
				co += m[i * (j+1)]
				co %= 2
			m[i] = (co ^ a[i-1])
			al += m[i]
		else:
			al %= 2
			m[0] = (al ^ m[1])
mmm = m[1:]
print(sum(mmm))
kkkk = [1 for i in range(sum(mmm))]
print(jo(kkkk))

Submission status: Wrong Answer

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


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


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

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

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

    return F

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

Submission status: Wrong Answer

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

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

cnt = a.count(1)
if cnt <= n:
    print(cnt)
    ans = []
    for i in range(n):
        if a[i] == 1:
            ans.append(i+1)
    print(" ".join(map(str,ans)))

else:
    print(-1)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [int(_) for _ in input().split()]
b = [0] * n
res = []
m = 0
for i in range(n):
    if b[i] != a[i]:
        for j in range(i,n,i+1):
            b[j] = (b[j]+1)%2
    if b[i] != 0:
        res.append(i+1)
        m += 1
if m == 0:
    print(0)
else:
    print(m)
    for i in range(m):
        if i != 0:
            print(' ',end='')
        print(res[i],end='',)
    print()

Submission status: Wrong Answer

Solution code:
import numpy as np
N = int(input())
a = np.array(list(map(int, input().split())), dtype='i')
b = np.zeros_like(a, dtype='i')
b[N//2:] = a[N//2:]
for i in reversed(range(N//2)):
    j = i+1
    b[i] = (np.sum(a[np.arange(2, N//j+1)*j-1]) + a[i])%2
print(np.sum(b))
w = np.where(b==1)[0]+1
print(''.join(list(map(str, w))))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [int(a) for a in input().split()]
flag = [0] * (n + 1)
ret = []
for i in range(n, 0, -1):
    if flag[i] ^ a[i - 1] == 1:
        ret.append(i)
    j = 1
    while j * j <= i:
        if i % j == 0:
            flag[j] ^= a[i - 1]
            if j * j != i:
                flag[i // j] ^= a[i - 1]
        j += 1
print(len(ret))
if len(ret) > 0:
    print(" ".join(map(str, ret)))

Submission status: Wrong Answer

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

for n in range(N-1, -1, -1):
    # for i in range(n, N, N // n):
    if N // (n+1) == 1:
        if A[n] == 1:
            B[n] = 1
            ans.append(n+1)
    else:
        C = [B[i] for i in range(n, N, N // (n+1))]
        if sum(C) % 2 != A[n]:
            B[n] = 1
            ans.append(n+1)

if A[0] == len(ans) % 2:
    print(len(ans))
    print(*ans, sep=" ")
else:
    print(0)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
A.insert(0, 0)
B = [0] * (N + 1)
for i in range(N, 0, -1):
  j = i * 2
  sum = 0
  while (j <= N):
    sum += B[j]
    j += i
  B[i] = (sum + A[i]) % 2
ans = ''
for i in range(1, N + 1):
  if B[i] == 1:
    ans += str(i) + ' '
print(0 if ans == '' else ans.strip())

Submission status: Wrong Answer

Solution code:
n = int(input())
l = list(map(int,input().split()))
half = n//2

cnt = 0
ans = [0]*n
for i in range(half,n):
    if l[i] == 1:
        ans[i] = 1
    else:
        ans[i] = 0
#print(ans)
for i in range(0,half):
    p = half-1-i
    a = n //(p+1)
    s = 0
    for j in range(1,a+1):
        s += ans[j*(p+1)-1]
    if s%2 != l[p]:
        ans[p] += 1
#print(ans)
print(sum(ans))
for i in range(n):
    if ans[i] == 1:
        print(i+1,end="")

Submission status: Wrong Answer

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

for i in range(N):
  b = sum(a[::i+1])
  if b%2 == a[i] :
    for j in range(N):
      if a[j] == 1:
        l.append(str(j+1))
    if len(l)!= 0:
      print(len(l))
      print(' '.join(l))
    else:
      print(len(l))
    break
  else:
    count += 1
if count == N :
  print(-1)

Submission status: Wrong Answer

Solution code:
def main():

    """ convenient functions
    # for i, a in enumerate(iterable)
    # q, mod = divmod(a, b)
    # divmod(x, y) returns the tuple (x//y, x%y)
    # Higher-order function: reduce(operator.mul, xyz_count, 1)
    # manage median(s) using two heapq https://atcoder.jp/contests/abc127/tasks/abc127_f
    """

    """convenient decorator
    # @functools.lru_cache():
    # to facilitate use of recursive function
        # ex:
        # from functools import lru_cache
        # import sys
        # sys.setrecursionlimit(10**9)
        # @lru_cache(maxsize=None)
        # def fib(n):
        #     if n < 2:
        #         return n
        #     return fib(n-1) + fib(n-2)
        # print(fib(1000))
    """
    
    # import numpy as np
    import sys
    sys.setrecursionlimit(10**7)
    from itertools import accumulate, combinations, permutations, product # https://docs.python.org/ja/3/library/itertools.html
    # accumulate() returns iterator! to get list: list(accumulate())
    from math import factorial, ceil, floor, sqrt
    def factorize(n):
        """return the factors of the Arg and count of each factor
        
        Args:
            n (long): number to be resolved into factors
        
        Returns:
            list of tuples: factorize(220) returns [(2, 2), (5, 1), (11, 1)]
        """
        fct = []  # prime factor
        b, e = 2, 0  # base, exponent
        while b * b <= n:
            while n % b == 0:
                n = n // b
                e = e + 1
            if e > 0:
                fct.append((b, e))
            b, e = b + 1, 0
        if n > 1:
            fct.append((n, 1))
        return fct
    def combinations_count(n, r):
        """Return the number of selecting r pieces of items from n kinds of items.
        
        Args:
            n (long): number
            r (long): number
        
        Raises:
            Exception: not defined when n or r is negative
        
        Returns:
            long: number
        """
        # TODO: How should I do when n - r is negative?
        if n < 0 or r < 0:
            raise Exception('combinations_count(n, r) not defined when n or r is negative')
        if n - r < r: r = n - r
        if r < 0: return 0
        if r == 0: return 1
        if r == 1: return n
        numerator = [n - r + k + 1 for k in range(r)]
        denominator = [k + 1 for k in range(r)]
        for p in range(2,r+1):
            pivot = denominator[p - 1]
            if pivot > 1:
                offset = (n - r) % p
                for k in range(p-1,r,p):
                    numerator[k - offset] /= pivot
                    denominator[k] /= pivot
        result = 1
        for k in range(r):
            if numerator[k] > 1:
                result *= int(numerator[k])
        return result
    def combinations_with_replacement_count(n, r):
        """Return the number of selecting r pieces of items from n kinds of items allowing individual elements to be repeated more than once.
        
        Args:
            n (long): number
            r (long): number
        
        Raises:
            Exception: not defined when n or r is negative
        
        Returns:
            long: number
        """
        if n < 0 or r < 0:
            raise Exception('combinations_with_replacement_count(n, r) not defined when n or r is negative')
        elif n == 0:
            return 1
        else:
            return combinations_count(n + r - 1, r)
    from bisect import bisect_left, bisect_right
    from collections import deque, Counter, defaultdict # https://docs.python.org/ja/3/library/collections.html#collections.deque
    from heapq import heapify, heappop, heappush, heappushpop, heapreplace,nlargest,nsmallest # https://docs.python.org/ja/3/library/heapq.html
    from copy import deepcopy, copy # https://docs.python.org/ja/3/library/copy.html
    import operator
    from operator import itemgetter
    # ex1: List.sort(key=itemgetter(1))
    # ex2: sorted(tuples, key=itemgetter(1,2))
    from functools import reduce, lru_cache
    def chmin(x, y):
        """change minimum
        if x > y, x = y and return (x, True).
        convenient when solving problems of dp[i]
        
        Args:
            x (long): current minimum value
            y (long): potential minimum value
        
        Returns:
            (x, bool): (x, True) when updated, else (x, False)
        """
        if x > y:
            x = y
            return (x, True)
        else:
            return (x, False)
    def chmax(x, y):
        """change maximum
        if x < y, x = y and return (x, True).
        convenient when solving problems of dp[i]
        
        Args:
            x (long): current maximum value
            y (long): potential maximum value
        
        Returns:
            (x, bool): (x, True) when updated, else (x, False)
        """
        if x < y:
            x = y
            return (x, True)
        else:
            return (x, False)

    from fractions import gcd # Deprecated since version 3.5: Use math.gcd() instead.
    def gcds(numbers):
        return reduce(gcd, numbers)
    def lcm(x, y):
        return (x * y) // gcd(x, y)
    def lcms(numbers):
        return reduce(lcm, numbers, 1)

    # first create factorial_list
    # fac_list = mod_factorial_list(n)
    INF = 10 ** 18
    MOD = 10 ** 9 + 7
    modpow = lambda a, n, p = MOD: pow(a, n, p) # Recursive function in python is slow!
    def modinv(a, p = MOD):
        # evaluate reciprocal using Fermat's little theorem:
        # a**(p-1) is identical to 1 (mod p) when a and p is coprime
        return modpow(a, p-2, p)
    def modinv_list(n, p = MOD):
        if n <= 1:
            return [0,1][:n+1]
        else:
            inv_t = [0,1]
            for i in range(2, n+1):
                inv_t += [inv_t[p % i] * (p - int(p / i)) % p]
            return inv_t
    def modfactorial_list(n, p = MOD):
        if n == 0:
            return [1]
        else:
            l = [0] * (n+1)
            tmp = 1
            for i in range(1, n+1):
                tmp = tmp * i % p
                l[i] = tmp
            return l
    def modcomb(n, k, fac_list = [], p = MOD):
        # fac_list = modfactorial_list(100)
        # print(modcomb(100, 5, modfactorial_list(100)))
        from math import factorial
        if n < 0 or k < 0 or n < k: return 0
        if n == 0 or k == 0: return 1
        if len(fac_list) <= n:
            a = factorial(n) % p
            b = factorial(k) % p
            c = factorial(n-k) % p
        else:
            a = fac_list[n]
            b = fac_list[k]
            c = fac_list[n-k]
        return (a * modpow(b, p-2, p) * modpow(c, p-2, p)) % p
    def modadd(a, b, p = MOD):
        return (a + b) % MOD
    def modsub(a, b, p = MOD):
        return (a - b) % p
    def modmul(a, b, p = MOD):
        return ((a % p) * (b % p)) % p
    def moddiv(a, b, p = MOD):
        return modmul(a, modpow(b, p-2, p))

    """ initialize variables and set inputs
    # initialize variables
        # to initialize list, use [0] * n
        # to initialize two dimentional array, use [[0] * N for _ in range(N)]
    # set inputs
        # open(0).read() is a convenient method:
        # ex) n, m, *x = map(int, open(0).read().split())
        #     min(x[::2]) - max(x[1::2])
        # ex2) *x, = map(int, open(0).read().split())
        #     don't forget to add comma after *x if only one variable is used
    # preprocessing
        # transpose = [x for x in zip(*data)]
        # ex) [[1, 2, 3], [4, 5, 6], [7, 8, 9]] => [(1, 4, 7), (2, 5, 8), (3, 6, 9)]
        # flat = [flatten for inner in data for flatten in inner]
        # ex) [[1, 2, 3], [4, 5, 6], [7, 8, 9]] => [1, 2, 3, 4, 5, 6, 7, 8, 9]
    # calculate and output
        # output pattern
        # ex1) print(*l) => when l = [2, 5, 6], printed 2 5 6
    """

    # functions used
    r = lambda: sys.stdin.readline().strip()
    r_int = lambda: int(r())
    R = lambda: list(map(int, r().split()))
    Rmap = lambda: map(int, r().split())
    Rfloat = lambda: list(map(float, r().split()))
    Rtuple = lambda: tuple(map(int, r().split()))

    """ how to treat input
    # single int: int(r())
    # single string: r()
    # single float: float(r())
    # line int: R()
    # line string: r().split()
    # line (str, int, int): [j if i == 0 else int(j) for i, j in enumerate(r().split())]
    # lines int: [R() for _ in range(n)]
    """

    if __name__ != '__main__':
        # for test
        sys.stdin = open('sample.txt')

    # ----------------------------------
    # main

    N = int(r())
    A = R()
    B = [0] * N
    for i in range(N):
        j = i + 1
        B[i] = sum(A[i::j])%2
    print(sum(B))
    if sum(B) != 0:
        C = []
        for i, b in enumerate(B):
            if b == 1:
                C.append(i+1)
        print(*C)
    
    # end of main
    # ----------------------------------

    """memo: how to use defaultdict of list
    # initialize
    Dic = defaultdict(list)
    # append / extend
    Dic[x].append(y)
    # for
    for k, v in Dic.items():
    """

if __name__ == '__main__':
    main()

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()
	A = [int(s) for s in A]

	ans = []
	hafe = N//2
	for i in range(N, 0, -1):
		if i > hafe:
			if A[i-1] == 1:
				ans.append(i)
				continue

		tmp = A[i-1]
		for j in range(2*i, N+1, i):
			tmp = tmp ^ A[j-1]
		if tmp == 1:
			ans.append(i)

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

		print(ans2[:-1])

if __name__ == "__main__":
	main()

Submission status: Wrong Answer

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

M = 0
for i in range(1, N + 1) :
    ret = 0
    for j in range(i, N + 1, i) :
        ret += a[j-1]
    if ret % 2 == 1 :
        M += 1
print(M)
print(' '.join([str(1) for _ in range(M)]))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import copy

N = int(input())
A = list(map(int, input().split()))
A.insert(0, 0)
B = copy.deepcopy(A)

if max(A) > 1:
	print("-1")
else:
	for i in range(N // 2, 0):
		total = 0
		for j in range(2 * i, N + 1, i):
			total += A[j]
		if total % 2 != A[i]:
			B[i] = 1
		else:
			B[i] = 0
			
	print(sum(B))
	for i in range(len(B)):
		if B[i] == 1:
			print(i, end = " ")

Submission status: Wrong Answer

Solution code:
import math

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

B = [str(N - i) for i in range(math.ceil(N / 2)) if A[N - i - 1] == 1]
C = [0] * math.floor(N / 2) + A[math.floor(N / 2):]

for i in range(math.floor(N / 2), 0, -1):
    count = 0
    for j in range(i, N + 1, i):
        print(j, C[j - 1])
        count += C[j - 1]
    if not count % 2 == A[i - 1]:
        B.append(str(i))
        C[i - 1] = 1

print(len(B))
if not len(B) == 0:
    print(" ".join(B))

Submission status: Wrong Answer

Solution code:
import sys

def main():
    input = sys.stdin.readline
    N = int(input())
    A = [0] + list(map(int, input().split()))

    M = 0
    ans = ''
    B = [0] * (N+1)
    for i in range(N, 0, -1):
        if A[i] != B[i]:
            M += 1
            ans = str(i) + ' ' + ans
            for j in range(1, int(i**(0.5))):
                if i % j == 0:
                    B[j] = (B[j] + 1) % 2

    if M == 0:
        print(0)
    else:
        print(M)
        print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:

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

a = [0] + a
b = [0] + b

m = N // 2

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

if len(ans) == 0:
    print(0)
else:
    print(len(ans))
    for i in range(len(ans)):
        if i == 0:
            print(ans[i], end="")
        else:
            print(" ", end="")
            print(ans[i], end="")

Submission status: Wrong Answer

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

for i in range(1, N+1):

    j = i
    sum_num = 0
    while j <= N:
        a = a_list[j-1]
        if j != i:
            sum_num += a
        if i == 1:
            j += 1
        else:
            j += i
    if sum_num % 2 == 0:
        if a_list[i-1] == 0:
            continue
        else:
            a_list[i-1] = 1
    else:
        if a_list[i-1] == 1:
            a_list[i-1] = 0
        else:
            a_list[i-1] = 1

ans = sum(a_list)
print(ans)

for i in range(1, N+1):
    if a_list[i-1] != 0:
        print(i)

Submission status: Wrong Answer

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

MOD = 2  # type: int

def solve(N: int, a: "List[int]"):
    a = [0] + a
    result = [0 for i in range(N+1)]
    for i in range(N, 0, -1):
        count_baisu = 1

        sum_ = 0
        while count_baisu * i <= N:
            sum_ += result[count_baisu * i]
            count_baisu += 1

        if a[i] == 0:
            if sum_ == 0:
                result[i] = 0
            else:
                result[i] = 1
        else:
            if sum_ == 0:
                result[i] = 1
            else:
                result[i] = 0
                
    print(sum(result))

    if sum(result) > 0:
        output = ''
        for i in range(1, N+1):
            if result[i] == 1:
                output += ' %d' % (i)
        print(output[1:])
    
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
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()