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
import heapq
import re
from itertools import permutations
from bisect import bisect_left, bisect_right
from collections import Counter, deque
from math import factorial, sqrt, ceil, gcd
from functools import lru_cache, reduce
from decimal import Decimal
INF = 1 << 60
MOD = 1000000007
sys.setrecursionlimit(10 ** 7)

# UnionFind
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

# ダイクストラ
def dijkstra_heap(s, edge, n):
    #始点sから各頂点への最短距離
    d = [10**20] * n
    used = [True] * n #True:未確定
    d[s] = 0
    used[s] = False
    edgelist = []
    for a,b in edge[s]:
        heapq.heappush(edgelist,a*(10**6)+b)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        #まだ使われてない頂点の中から最小の距離のものを探す
        if not used[minedge%(10**6)]:
            continue
        v = minedge%(10**6)
        d[v] = minedge//(10**6)
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,(e[0]+d[v])*(10**6)+e[1])
    return d

# 素因数分解
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

# 2数の最小公倍数
def lcm(x, y):
    return (x * y) // gcd(x, y)

# リストの要素の最小公倍数
def lcm_list(numbers):
    return reduce(lcm, numbers, 1)

# リストの要素の最大公約数
def gcd_list(numbers):
    return reduce(gcd, numbers)

# 素数判定
def is_prime(n):
    if n <= 1:
        return False
    p = 2
    while True:
        if p ** 2 > n:
            break
        if n % p == 0:
            return False
        p += 1
    return True


# limit以下の素数を列挙
def eratosthenes(limit):
    A = [i for i in range(2, limit+1)]
    P = []

    while True:
        prime = min(A)
        
        if prime > sqrt(limit):
            break
            
        P.append(prime)
            
        i = 0
        while i < len(A):
            if A[i] % prime == 0:
                A.pop(i)
                continue
            i += 1
            
    for a in A:
        P.append(a)
            
    return P

# 同じものを含む順列
def permutation_with_duplicates(L):

    if L == []:
        return [[]]

    else:
        ret = []

        # set（集合）型で重複を削除、ソート
        S = sorted(set(L))

        for i in S:

            data = L[:]
            data.remove(i)

            for j in permutation_with_duplicates(data):
                ret.append([i] + j)

        return ret

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

# ここから書き始める
n = int(input())
a = list(map(int, input().split()))

x = [[] for i in range(n)]
for i in range(n):
    d = make_divisors(i + 1)
    for j in d:
        x[j - 1].append(i + 1)

ans = [0 for i in range(n)]
for i in reversed(range(n)):
    total = 0
    for j in x[i]:
        total += ans[j - 1]
    if total % 2 != a[i]:
        ans[i] = 1
# print("ans =", ans)

m = ans.count(1)
print(m)
for i in range(m):
    print(1)

Submission status: Wrong Answer

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

for i in reversed(range(1,N+1)):
    if i > N // 2:
        if A[i-1] == 1:
            ans.append(i)
            chk[i-1] = 1
            cnt += 1
    else:
        j = 2 * i
        ret = 0
        while j <= N:
            ret += chk[i-1] 
            j += i
        if A[i-1] != ret%2:
            ans.append(i)
            chk[i-1] = 1
            cnt += 1
            
print(cnt)
print(*ans)

Submission status: Wrong Answer

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

for i in reversed(range(1,N+1)):
    if i > N //2:
        if A[i-1] == 1:
            ans.append(i)
            chk[i-1] = 1
            cnt += 1
    else:
        j = 2 * i
        ret = 0
        while j <= N:
            ret += chk[i] 
            j += i
        if A[i-1] != ret%2:
            ans.append(i)
            chk[i-1] = 1
            cnt += 1
            
print(cnt)
print(*ans)

Submission status: Wrong Answer

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

for i in reversed(range(1,N+1)):
    if i > N //2:
        if A[i-1] == 1:
            ans.append(i)
            cnt += 1
    else:
        if A[i-1] != A[2*i-1]:
            ans.append(i)
            cnt += 1
print(cnt)
print(*ans)

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):
    j = 2*i - 1
    now = 0
    while j < N:
        now += ans[j]
        j += i
    if now % 2 == a[i-1]:
        ans.append(0)
    else:
        ans.append(1)

ans.reverse()
S = sum(ans)
print(S)
if S:
    print(*[i+1 for i in range(N) if ans[i]])

Submission status: Wrong Answer

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

for i in range(N, 0, -1):
    j = 2*i - 1
    now = 0
    while j < N:
        now += a[j]
        j += i
    if now % 2 == a[i-1]:
        ans.append(0)
    else:
        ans.append(1)

ans.reverse()
S = sum(ans)
print(S)
if S:
    print(*[i+1 for i in range(N) if ans[i]])

Submission status: Wrong Answer

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

for i in range(N, 0, -1):
    j = 2*i - 1
    now = 0
    while j < N:
        now += a[j]
        j += i
    if now % 2 == a[i-1]:
        ans.append(0)
    else:
        ans.append(1)

ans.reverse()
S = sum(ans)
print(S)
if S:
    print(*[i+1 for i in range(N) if ans[i]])

Submission status: Wrong Answer

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

for i in range(N, 0, -1):
    j = 2*i - 1
    now = 0
    while j < N:
        now += a[j]
        j += i
    if now % 2 == a[i-1]:
        ans.append(0)
    else:
        ans.append(1)

S = sum(ans)
print(S)
if S:
    print(*[N-i for i in range(N-1, -1, -1) if ans[i]])

Submission status: Wrong Answer

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

print(sum(a))
if sum(a):
    print(*[i+1 for i in range(N) if a[i]])

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
res=[0]*n
for i in reversed(range(1,n+1)):
  sm=0
  for j in range(2,n//i+1):
    sm+=res[i*j-1]
  res[i-1] = a[i-1] ^ sm
  
ans = [i+1 for i in range(n) if res[i]>0]
print(len(ans))
if len(ans):
  print(*ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

b =[0]*(n+1)

ans = 0

for i in range(n):
  j = n-i
  sum = 0
  m = 1
  while j*m <= n:
    sum += b[j*m]
    m += 1
  if sum % 2 != a[j-1]:
    b[j] = 1 
    ans += 1
    
print(ans)

if not 1 in b:
  print(0)
else:
  for i in range(n+1):
    if b[i] == 1:
      print(i, end =' ')

Submission status: Wrong Answer

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

b =[0]*(n+1)

for i in range(n):
  j = n-i
  sum = 0
  m = 1
  while j*m <= n:
    sum += b[j*m]
    m += 1
  if sum % 2 != a[j-1]:
    b[j] = 1  
    
print(1)

ans =[]

if not 1 in b:
  print(0)
else:
  for i in range(n+1):
    if b[i] == 1:
      print(i, end =' ')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
from collections import defaultdict


def read():
    N = int(input().strip())
    A = list(map(int, input().strip().split()))
    return N, A


def divisor(n):
    i = 1
    d = []
    while i * i <= n:
        if n % i == 0:
            d.append(i)
            if i * i != n:
                d.append(n // i)
        i += 1
    return d


def solve(N, A):
    use = [1 for i in range(N+1)]
    for i in range(N, 0, -1):
        multiple = sum([use[i] for i in range(i+i, N, i)])
        if A[i-1] == (1 + multiple) % 2:
            use[i] = 1
        else:
            use[i] = 0
    ans = [i for i in range(1, N+1) if use[i]]
    print(len(ans))
    if len(ans) > 0:
        print(*ans)


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
from collections import defaultdict


def read():
    N = int(input().strip())
    A = list(map(int, input().strip().split()))
    return N, A


def divisor(n):
    i = 1
    d = []
    while i * i <= n:
        if n % i == 0:
            d.append(i)
            if i * i != n:
                d.append(n // i)
        i += 1
    return d


def solve(N, A):
    ans = [1 for i in range(N+1)]
    for i in range(N, 0, -1):
        multiple = sum([ans[i] for i in range(i+i, N, i)])
        if A[i-1] == (1 + multiple) % 2:
            ans[i] = 1
        else:
            ans[i] = 0
    ans = [i for i in range(1, N+1) if ans[i]]
    print(len(ans))
    print(*ans)


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
from collections import defaultdict


def read():
    N = int(input().strip())
    A = list(map(int, input().strip().split()))
    return N, A


def divisor(n):
    i = 1
    d = []
    
    return d


def solve(N, A):
    ans = set()
    for i in range(N, 0, -1):
        if A[i-1] == 1:
            ans.add(i)
            d = 1
            while d * d <= N:
                if N % d == 0:
                    A[d-1] ^= 1
                    if d * d != N:
                        A[N//d-1] ^= 1
                d += 1
    print(len(ans))
    print(*ans)


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
from collections import defaultdict


def read():
    N = int(input().strip())
    A = list(map(int, input().strip().split()))
    return N, A


def sieve(n):
    """
    n以下の素数を昇順に列挙する
    """
    is_prime = [True for i in range(n+1)]
    primes = []
    for i in range(2, n+1):
        if is_prime[i]:
            primes.append(i)
            for j in range(i+i, n+1, i):
                is_prime[j] = False
    return primes


def divisor(n, primes):
    i = 1
    d = []
    d.append(1)
    if n > 1:
        d.append(n)
    for p in primes:
        if n % p == 0:
            d.append(p)
            if p * p != n:
                d.append(n // p)
    return d


def solve(N, A):
    primes = sieve(N)
    ans = []
    for i in range(N, 0, -1):
        if A[i-1] == 1:
            ans += [i]
            for d in divisor(i, primes):
                A[d-1] ^= 1
    print(len(ans))
    print(*ans)


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
from itertools import accumulate


def read():
    N = int(input().strip())
    A = list(map(int, input().strip().split()))
    return N, A


def solve(N, A):
    # sieve
    factor = [i for i in range(N+1)]
    for i in range(2, N+1):
        if i == factor[i]:
            for j in range(i + i, N+1, i):
                factor[j] = i
    ans = []
    for i in range(N, 0, -1):
        if A[i-1] == 1:
            ans += [i]
            k = i
            A[k-1] ^= 1
            while k > 1 and k != factor[k]:
                k = factor[k]
                A[k-1] ^= 1
            A[0] ^= 1
    print(len(ans))
    print(*ans)


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np

N = int(input())
A = np.array(list(map(int, input().split())))
ans_list = np.zeros(N).astype(int)
N_2 = N // 2
ans = 0
for i in range(N):
    tmp = N - i - 1
    # print(tmp)
    if i < N_2:
        ans_list[tmp] = A[tmp]
        if A[tmp] == 1:
            ans += 1
    else:
        add = (np.sum(ans_list[tmp::(tmp + 1)]) + A[tmp]) % 2
        ans_list[tmp] = add
        if add == 1:
            ans += 1

print(ans)
for i in range(N):
    if ans_list[i] == 1:
        if i == N-1:
            print(ans_list[i], end="")
        else:
            print(ans_list[i], end=" ")

Submission status: Wrong Answer

Solution code:
import numpy as np

N = int(input())
A = np.array(list(map(int, input().split())))
ans_list = np.zeros(N).astype(int)
N_2 = N // 2
ans = 0
for i in range(N):
    tmp = N - i - 1
    # print(tmp)
    if i < N_2:
        ans_list[tmp] = A[tmp]
        if A[tmp] == 1:
            ans += 1
    else:
        add = (np.sum(ans_list[tmp::(tmp + 1)]) + A[tmp]) % 2
        ans_list[tmp] = add
        if add == 1:
            ans += 1

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

Submission status: Wrong Answer

Solution code:
import numpy as np

N = int(input())
A = np.array(list(map(int, input().split())))
ans_list = np.zeros(N).astype(int)
N_2 = N // 2
for i in range(N):
    tmp = N - i - 1
    # print(tmp)
    if i < N_2:
        ans_list[tmp] = A[tmp]
    else:
        ans_list[tmp] = (np.sum(ans_list[tmp::(tmp+1)]) + A[tmp]) % 2

print(np.sum(ans_list))
for i in range(N):
    if ans_list[i] == 1:
        print(ans_list[i], end="")

Submission status: Wrong Answer

Solution code:
n   = int(input())
li  = list(map(int,input().split()))
ans  = [0]*n
ans2 = 0
ans3 = []
mtp  = 0

for i in range(n,0,-1):
    tmp = 0
    if n//i == 1:
        ans[i-1] = li[i-1]
    else:
        mtp = n//i
        for j in range(1,mtp):
            tmp += li[i*(j+1)-1]
        tmp %= 2

        if tmp==0:
            ans[i-1] = (0^li[i-1])
        else:
            ans[i-1] = (1^li[i-1])

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

print(ans2)
print(*ans3)

Submission status: Wrong Answer

Solution code:
n   = int(input())
li  = list(map(int,input().split()))
ans = [0]*n
ans2 = 0
ans3 = []
mtp = 0

for i in range(n,0,-1):
    tmp = 0
    if n//i == 1:
        ans[i-1] = li[i-1]
    else:
        mtp = n//i
        for j in range(1,mtp):
            tmp += li[i*(j+1)-1]
        tmp %= 2

        if tmp==0:
            ans[i-1] = li[i-1]
        else:
            ans[i-1] = (1^li[i-1])

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

print(ans2)
print(*ans3)

Submission status: Wrong Answer

Solution code:
import sys
import itertools
# import numpy as np
import time
import math
 
sys.setrecursionlimit(10 ** 7)
 
from collections import defaultdict
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

B = [0] * (N + 1)
for i in range(N, 0, -1):
    j = i
    total = 0
    while j < N:
        total += B[j]
        j += i
    if A[i - 1]:
        if total % 2 == 0:
            B[i] = 1
        else:
            B[i] = 0
    else:
        if total % 2 == 0:
            B[i] = 0
        else:
            B[i] = 1

print(sum(B))
for i in range(len(B)):
    if B[i] == 1:
        print(i)

Submission status: Wrong Answer

Solution code:
import sys
import itertools
# import numpy as np
import time
import math
 
sys.setrecursionlimit(10 ** 7)
 
from collections import defaultdict
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

B = [0] * (N + 1)
for i in range(N, 0, -1):
    j = i
    total = 0
    while j < N:
        total += B[j]
        j += i
    if total % 2 == A[i - 1]:
        B[i] = 0
    else:
        B[i] = 1

print(sum(B))
for i in range(len(B)):
    if B[i] == 1:
        print(i)

Submission status: Wrong Answer

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

print(-1)

Submission status: Wrong Answer

Solution code:
#d
n = int(input())
a = list(map(int, input().split()))
ans = [0]*len(a)
for i in range(len(a),0,-1):
    if sum(ans[i-1::i])%2 != a[i-1]:
        ans[i-1] = 1
print(sum(ans))
if sum(ans) > 0:
    ans=[str(a) for a in ans]
    ans=" ".join(ans)
    print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#d
n = int(input())
a = list(map(int, input().split()))
print(-1)

Submission status: Wrong Answer

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

on = -1

if all(a) != True:
    print(0)
    exit()

sm = sum(a)

if sm % 2 == a[0]:
    on = 1
    print(1)
    print(on)
    exit()

print(0)

Submission status: Wrong Answer

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

one_index = list()
for num in range(len(a)):
    if a[num] == 1:
        one_index.append(num + 1)
        
if not one_index:
    print("0")
    exit()

ans_index = list()

for index_num in one_index:
    kosu = 0
    #print(index_num)
    for num in one_index[index_num -1:]:
        #print(num)
        if num % index_num == 0:
            kosu += 1
    if kosu % 2 == a[index_num -1]:
        ans_index.append(str(index_num))

ans_len = len(ans_index)
if ans_len > 0:
    print(ans_len)
    print(" ".join(ans_index))
else:
    print(-1)

Submission status: Wrong Answer

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

one_index = list()
for num in range(len(a)):
    if a[num] == 1:
        one_index.append(num + 1)
        
if not one_index:
    print("0")
    exit()

ans_index = list()

for index_num in one_index:
    kosu = 0
    for num in one_index:
        if num % index_num == 0:
            kosu += 1
    if kosu % 2 == a[index_num -1]:
        ans_index.append(str(index_num))

ans_len = len(ans_index)
if ans_len > 0:
    print(ans_len)
    print(" ".join(ans_index))
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
n = int(input())
L=list(map(int, input().split()))
B=[0]*n
A=[]
cnt=0
def make_divisors(n):
    divisors = set()
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.add(i)
            if i != n // i:
                divisors.add(n//i)
    return divisors

for i in reversed(range(n)):
	if L[i]!=B[i]:
		A.append(i+1)
		cnt+=1
		for j in make_divisors(i+1):
			B[j-1]+=1
    
print(cnt)
print(*A)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
box = [0]*n
for i in range(n,0,-1):
  k = a[i-1]
  c = 0
  for j in range(1,n//i+1):
    c += box[i*j-1]
  if c%2 != k:
    box[i-1] = 1
ans = []
w = 0
for m in range(n):
  if box[m] == 1:
    w += 1
    ans.append(str(i+1))
print(w)
print(' '.join(ans))

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
B = [0] * (N+1)
for i in range(N, 0, -1):
  a = A[i-1]
  j = 2
  prev = 0
  while i*j < (N+1):
    prev ^= A[i*j-1]
    j += 1
  B[i] = a ^ prev

print(B.count(1))
if B.count(1) > 0:
  print(" ".join(map(str, [ i for i,b in enumerate(B) if b==1 ])))

Submission status: Wrong Answer

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

sum = [0]*(n+1)

for i in range(1,n+1):
	for k in range(1,math.floor(n/i)+1):
		j = int(k*i)
		sum[i] += a[j-1]

L = [i for i in range(n) if sum[i]%2 == 1]
print(len(L))
M=[str(a) for a in L]
M=" ".join(M)
print(M)

Submission status: Wrong Answer

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

sum = [0]*(n+1)

for i in range(1,n+1):
	for k in range(1,math.floor(n/i)+1):
		j = int(k*i)
		sum[i] += a[j-1]

L = [i for i in range(n) if sum[i]%2 == 1]
M=[str(a) for a in L]
print(len(M))
M=" ".join(M)
print(M)

Submission status: Wrong Answer

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

sum = [0]*(n+1)

for i in range(1,n+1):
	for k in range(1,math.floor(n/i)+1):
		j = int(k*i)
		sum[i] += a[j-1]

L = [i for i in range(n) if sum[i]%2 == 1]
M=[str(a) for a in L]
M=" ".join(M)
print(len(M))
print(M)

Submission status: Wrong Answer

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

sum = [0]*(n+1)

for i in range(1,n+1):
	for k in range(1,math.floor(n/i)+1):
		j = int(k*i)
		sum[i] += a[j-1]

L = [i for i in range(n) if sum[i] == 1]
M=[str(a) for a in L]
M=" ".join(M)
print(len(M))
print(M)

Submission status: Wrong Answer

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

sum = [0]*(n+1)

for i in range(1,n+1):
	for k in range(1,math.floor(n/i)+1):
		j = int(k*i)
		sum[i] += a[j-1]

L = [i+1 for i in range(n) if a[i] == 1]
M=[str(a) for a in L]
M=" ".join(M)
print(len(M))
print(M)

Submission status: Wrong Answer

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

hako=[0]*n
for i in range(n):
    if sum(hako[n-i-1:n:n-i])!=a[n-i-1]:
        hako[n-i-1]+=1

ans=[]
for i in range(n):
    if hako[i]==1:
        ans.append(str(i+1))
        
print(sum(hako))
if ans:
    print(' '.join(ans))

Submission status: Wrong Answer

Solution code:
import sys

input = lambda: sys.stdin.readline().rstrip()


def solve():

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

    oe = [0] + [-1 for i in range(N)]

    for i in range(N, 0, -1):
        num = i
        j = 1
        flag = True if A[i] == 0 else False
        while num <= N:
            if oe[num] == -1:
                oe[num] = flag
            else:
                f = True if oe[num] == 0 else False
                flag = not(flag ^ f)
            j += 1
            num = i * j

    oe.pop(0)
    ans = []
    for i, f in enumerate(oe):
        if not f:
            ans.append(i + 1)

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


if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

Solution code:
import sys

input = lambda: sys.stdin.readline().rstrip()


def solve():

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

    oe = [0] + [-1 for i in range(N)]

    for i in range(N, 0, -1):
        num = i
        j = 1
        flag = True if A[i] == 0 else False
        while num <= N:
            if oe[num] == -1:
                oe[num] = flag
            else:
                f = True if oe[num] == 0 else False
                flag = not(flag ^ f)
            j += 1
            num = i * j

    oe.pop(0)
    oe = [2 if f else 1 for f in oe]
    print(len(oe))
    if len(oe):
        print(' '.join(map(str, oe)))


if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

Solution code:
import sys

input = lambda: sys.stdin.readline().rstrip()


def solve():

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

    oe = [0] + [-1 for i in range(N)]

    for i in range(N, 0, -1):
        num = i
        j = 1
        flag = True if A[i] == 0 else False
        while num <= N:
            if oe[num] == -1:
                oe[num] = flag
            else:
                f = True if oe[num] == 0 else False
                flag = not(flag ^ f)
            j += 1
            num = i * j

    print(oe)
    oe.pop(0)
    oe = [2 if f else 1 for f in oe]
    print(len(oe))
    if len(oe):
        print(' '.join(map(str, oe)))


if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

Solution code:
import sys

input = lambda: sys.stdin.readline().rstrip()


def solve():

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

    oe = [0] + [-1 for i in range(N)]

    for i in range(N, 0, -1):
        num = i
        j = 1
        flag = True if A[i] == 0 else False
        while num <= N:
            if oe[num] == -1:
                oe[num] = flag
            else:
                f = True if oe[num] == 0 else False
                flag = not(flag ^ f)
            j += 1
            num = i * j

    oe.pop(0)
    oe = [1 for f in oe if not(f)]
    print(len(oe))
    if len(oe):
        print(' '.join(map(str, oe)))


if __name__ == '__main__':
    solve()