Problem:


Score : 400 points

Problem Statement

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

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

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

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

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

Constraints

All values in input are integers.

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

a_i is 0 or 1.

Input

Input is given from Standard Input in the following format:

N
a_1 a_2 ... a_N

Output

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

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

M
b_1 b_2 ... b_M

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

Sample Input 1

3
1 0 0

Sample Output 1

1
1

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

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

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

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

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

Sample Input 2

5
0 0 0 0 0

Sample Output 2

0

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



Sample input:
3
1 0 0


Sample output:
1
1

Submission status: Wrong Answer

Solution code:
n = int(input())
array = [int(x) for x in input().split()]
ans = [0 for x in range(n)]
res = []
count = 0
for i in reversed(range(n)):
    a = array[i]
    if a == 1 and sum([x for x in ans[i::i+1]]) % 2 == 0:
        ans[i] = 1
        count += 1
        res.append(str(a))
    elif a == 0 and sum([x for x in ans[i::i+1]]) % 2 == 1:
        ans[i] = 1
        count += 1
        res.append(str(a))
print(count)
print(" ".join(res))

Submission status: Wrong Answer

Solution code:
N = int(input())
b = list(map(int,input().split()))
box = [0 for i in range(N)]

for i in range(N-1,-1,-1):
  rest = 0
  for j in range(2 * (i+1),N+1,i+1):
    rest += box[j-1]
  box[i] = (b[i] - rest)%2
print(sum(box))

Submission status: Wrong Answer

Solution code:
def divisor(i):
    num=int(i**0.5)
    div_list=[]
    for j in range(1,num+1):
        if i%j==0:
            div_list.append(j)
            div_list.append(i//j)
    return set(div_list)

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

ans=[0]*n
num=0
for i in range(n-1,-1,-1):
    if a[i]==1 and ans[i]==0:
        num+=1
        l=divisor(i+1)
        for j in l:
            ans[j-1]=(ans[j-1]+1)%2
#print(ans)
print(num)
for x,y in enumerate(ans,1):
    if y==1:
        print(x,end=' ')

Submission status: Wrong Answer

Solution code:
def divisor(i):
    num=int(i**0.5)
    div_list=[]
    for j in range(1,num+1):
        if i%j==0:
            div_list.append(j)
            div_list.append(i//j)
    return set(div_list)

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

ans=[0]*n
for i in range(n-1,-1,-1):
    if a[i]==1:
        l=divisor(i+1)
        for j in l:
            ans[j-1]=(ans[j-1]+1)%2
#print(ans)
print(sum(ans))
for x,y in enumerate(ans,1):
    if y==1:
        print(x,end=' ')

Submission status: Wrong Answer

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

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

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

ans = [str(i+1) for i, x in enumerate(b) if x == 1]
print(len(ans))
if len(ans) != 0:
    print(" ".join(ans))

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
A = [0] + lr()
answer = np.zeros(N+1, np.int16)
for i in range(N, 0, -1):
    a = A[i]
    result = answer[i::i].sum()
    if result % 2 != a:
        answer[i] = 1

print(*answer[1:])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
A = list(map(int, input().split()))
ans = [0] * n
for itr, val in enumerate(A[::-1]):
  idx = n - itr
  if sum([ans[(i + 1) * idx - 1] for i in range(n // idx)]) % 2 != val:
    ans[idx - 1] = int(not ans[itr])

# print(ans)
    
p = sum(ans)
print(p)    

if p > 0:
  print(*[i + 1 for i, j in enumerate(ans) if j == 1])

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
n = int(input())
a = [int(i) for i in input().split()]

count = [0 for _ in range(n)]
for i in reversed(range(1, n + 1)):
    tmp = 0
    for j in range(i, n, i):
        tmp += a[j-1]
    if a[i-1] % 2 != tmp % 2:
        count[i-1] += 1
m = sum(count)
ans = []
for i in range(n):
    if count[i] == 1:
        ans.append(str(i))

print(m)
print(' '.join(ans))

Submission status: Wrong Answer

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

N = int(input())
a = [int(s) for s in input().split()]
b = [0]*N
sum_box = 0
index = 2
list_box = []

for i in range(N-1,-1,-1):
    if (i+1) <= N//index:
        index += 1

    if sum(b[i::(N//(index-1))]) % 2 != a[i]:
        b[i] = 1
        sum_box += 1
        list_box.append(str(i+1))
        
print(sum_box)
    
if sum_box > 0:
    print(''.join(list_box))

Submission status: Wrong Answer

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

N = int(input())
a = [int(s) for s in input().split()]
b = [0]*N
sum_box = 0
index = 2
list_box = []

for i in range(N-1,-1,-1):
    if (i+1) <= N//index:
        index += 1

    if sum(b[i::(N//(index-1))]) % 2 != a[i]:
        b[i] = 1
        sum_box += 1
        list_box.append(str(i+1))
        
print(sum_box)
    
if sum_box > 0:
    print(''.join(list_box))

Submission status: Wrong Answer

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

MOD = 2  # type: int


def solve(N: int, a: "List[int]"):
    return


# Generated by 1.1.6 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():
    N = int(input())
    a = [int(s) for s in input().split()]
    b = [0]*N
    sum_box = 0
    index = 2
    list_box = []

    for i in range(N-1,-1,-1):
        if (i+1) <= N//index:
            index += 1

        if sum(b[i::(N//(index-1))]) % 2 != a[i]:
            b[i] = 1
            sum_box += 1
            list_box.append(str(i+1))
        
    print(sum_box)
    
    if sum_box > 0:
        print(''.join(list_box))
    

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
A = LIST()
#ball
X = [0] * (N + 1)
for i in range(N, 0, -1):
    # num = i+1
    tmp = A[i-1]
    # ここから上のボール
    for j in range(i, N+1, i):
        #これなかった
        if j == i:
            continue
        # AではなくボールXと
        # tmp ^= A[j-1]
        tmp ^= X[j]
    # X[i] = tmp ^ A[i]
    X[i] = tmp
    
    # if tmp == 0:
    #     X[i] = 0
    # else:
    #     X[i] = 1
# print(X)
# if sum(X) == 0:
#     print(sum(X))
#     exit()
print(sum(X))
ans = []
for i in range(N):
    if X[i] == 1:
        ans.append(i)
print(*ans)

Submission status: Wrong Answer

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

B = [0]*n

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(reverse=True)
    return divisors

for i in reversed(range(n)):
    j = i+1
    l = make_divisors(j)
    cnt = B[i]
    for k in l:
        if (A[k-1]-cnt)%2 == 0:
            B[k-1] += 0
            cnt += 0
        else:
            B[k-1] += 1
            cnt += 1
m = 0
ans = []
for i, b in enumerate(B):
    if b != 0:
        m += 1
        ans.append(i+1)
print(m)
if len(ans) > 0:
    print(*ans)

Submission status: Wrong Answer

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

B = [0]*n

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(reverse=True)
    return divisors

for i in reversed(range(n)):
    j = i+1
    l = make_divisors(j)
    cnt = 0
    for k in l:
        if (A[k-1]-cnt)%2 == 0:
            B[k-1] += 0
            cnt += 0
        else:
            B[k-1] += 1
            cnt += 1
m = 0
ans = []
for i, b in enumerate(B):
    if b != 0:
        m += 1
        ans.append(i+1)
print(m)
if len(ans) > 0:
    print(*ans)

Submission status: Wrong Answer

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

B = [0]*n

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(reverse=True)
    return divisors

for i in reversed(range(n)):
    j = i+1
    l = make_divisors(j)
    cnt = 0
    for k in l:
        if (A[k-1]-cnt)%2 == 0:
            B[k-1] += 0
            cnt += 0
        else:
            B[k-1] += 1
            cnt += 1
#print(B)
m = sum(B)
ans = []
for i, b in enumerate(B):
    if b != 0:
        ans.append(i+1)
print(m)
if len(ans) > 0:
    print(*ans)

Submission status: Wrong Answer

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
A = LIST()
#ball
X = [0] * (N + 1)
for i in range(N-1, -1, -1):
    # num = i+1
    tmp = A[i]
    # ここから上のボール
    for j in range(i+1, N+1, i+1):
        #これなかった
        if j == i:
            continue
        # AではなくボールXと
        # tmp ^= A[j-1]
        tmp ^= X[j]
    # X[i] = tmp ^ A[i]
    X[i] = tmp
    
    # if tmp == 0:
    #     X[i] = 0
    # else:
    #     X[i] = 1
# print(X)
if sum(X) == 0:
    print(sum(X))
    exit()
print(sum(X))
ans = []
for i in range(N):
    if X[i] == 1:
        ans.append(i+1)
print(*ans)

Submission status: Wrong Answer

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

B = [0]*n

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(reverse=True)
    return divisors

for i in reversed(range(n)):
    j = i+1
    l = make_divisors(j)
    cnt = 0
    for k in l:
        if (A[k-1]-cnt)%2 == 0:
            B[k-1] = 0
            cnt += 0
        else:
            B[k-1] = 1
            cnt += 1
#print(B)
m = sum(B)
ans = []
for i, b in enumerate(B):
    if b != 0:
        ans.append(i+1)
print(m)
if len(ans) > 0:
    print(*ans)

Submission status: Wrong Answer

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

B = [0]*n
C = [-1]*n

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(reverse=True)
    return divisors

for i in reversed(range(n)):
    j = i+1
    l = make_divisors(j)
    cnt = 0
    for k in l:
        if C[k-1] != -1:
            continue
        if (A[k-1]-cnt)%2 == 0:
            B[k-1] = 0
            cnt += 0
            C[k-1] = 0
        else:
            B[k-1] = 1
            cnt += 1
            C[k-1] = 0
#print(B)
m = sum(B)
ans = []
for i, b in enumerate(B):
    if b != 0:
        ans.append(i+1)
print(m)
if len(ans) > 0:
    print(*ans)

Submission status: Wrong Answer

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
A = LIST()
X = [0] * N
for i in range(N-1, -1, -1):
    num = i+1
    tmp = 0
    # ここから上のボール
    for j in range(i+1, N, i+1):
        tmp ^= A[j]
    X[i] = tmp ^ A[i]
    # if tmp == 0:
    #     X[i] = 0
    # else:
    #     X[i] = 1
# print(X)
if sum(X) == 0:
    print(sum(X))
    exit()
print(sum(X))
ans = []
for i in range(N):
    if X[i] == 1:
        ans.append(i+1)
print(*ans)

Submission status: Wrong Answer

Solution code:
import sys

def div(i):
    ans = []
    for d in range(1, i + 1):
        if i % d == 0:
            if d ** 2 == i: ans.append(d)
            else:
                ans.append(d)
                ans.append(i // d)
    return ans

def solve():
    input = sys.stdin.readline
    N = int(input())
    A = [int(a) for a in input().split()]
    Count = [0] * N
    In = []
    add = 0
    for i in reversed(range(N)):
        if Count[i] % 2 == A[i]: continue
        elif (Count[i] + 1) % 2 == A[i]:
            add += 1
            In.append(i + 1)
            D = div(i + 1)
            for d in D: Count[d - 1] += 1
        else:
            print(-1)
            break
    else:
        print(add)
        print(" ".join(map(str, In)))

    return 0

if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
ind = list(range(1, N+1))


B = [0] * (N + 1)
for i in reversed(range(1, N + 1)):
    if i > N // 2:
        B[i] = A[i - 1]
        continue

    cnt = 0
    x = i * 2
    while x <= N:
        cnt += B[x]
        x += i
    B[i] = cnt ^ A[i - 1]

ans = [i for i in range(1, N+1) if B[i] == 1]
print(len(ans))
if ans:
    print(*ans)

Submission status: Wrong Answer

Solution code:
import math
N = int(input())
a = list(map(int,input().split()))
b = [0]*N
ans = []
for k in range(N,0,-1):
    if a[k-1]%2 != b[k-1]%2:
        ans.append(k)
        b[0] += 1
        b[k-1] += 1
        for l in range(2,math.floor(math.sqrt(k))+1):
            if k % l == 0:
                if l*l == k:
                    b[l-1] += 1
                else:
                    b[l] += 1
                    b[k//l] += 1
print(len(ans))
if len(ans) > 0:
    print(*ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
ind = list(range(1, N+1))


B = [0] * (N + 1)
for i in reversed(range(1, N + 1)):
    if i > N // 2:
        B[i] = A[i - 1]
        continue

    cnt = 0
    x = i * 2
    while x <= N:
        cnt += B[x]
        x += i
    B[i] = cnt ^ A[i - 1]

ans = [i for i in range(1, N) if B[i] == 1]
print(len(ans))
if ans:
    print(*ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
ind = list(range(1, N+1))
A = A[::-1]
ind = ind[::-1]


def div(n):
    res = set()
    for i in range(1, int(n ** 0.5 + 0.5) + 1):
        if n % i == 0:
            res.add(i)
            res.add(n // i)
    return res


ans = [0] * (N + 1)
for n, a in zip(ind, A):
    if a == 1:
        if ans[n] % 2 == 0:
            ans[n] += 1
        for d in (div(n)-{n}):
            ans[d] += 1
    else:
        if ans[n] % 2 == 1:
            ans[n] += 1

answer = []
for i, x in enumerate(ans[1:], start=1):
    if x % 2 == 1:
        answer.append(i)

print(len(answer))
if answer:
    print(*answer)

Submission status: Wrong Answer

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

box = [0]*N
ans = []
for n in range(N,0,-1):
    c = 0
    for i in range(n,N,n):
        c += box[i-1]
    c %= 2
    if A[n-1] != c:
        box[n-1] = 1
        ans.append(n)
print(len(ans))
if ans:
    print(*ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [0] + [int(s) for s in input().split(' ')]

B = [0] * (N + 1)
count = 0
ret = []
for i in range(N, 0, -1):
    ai = A[i]
    ii = i
    total = 0
    while ii < N:
        total += B[ii]
        ii += i
    
    if total % 2 == ai:
        continue
    else:
        B[i] = 1
        count += 1
        ret.append(i)

print(count)
print(' '.join(str(i) for i in ret))

Submission status: Wrong Answer

Solution code:
# 6     1 2 3 4 5 6
# aaa = 1 1 0 1 1 1
# bbb = x x x x x 1 | k / 2まではa[i] と同じ
# bbb = x x x x 1 1 | k / 2まではa[i] と同じ
# bbb = x x x 1 1 1 | k / 2まではa[i] と同じ
# bbb = x 1 1 1 1 1 | sum_b[6] % 2 == 1 で != 0(a[1]) なので 1
# bbb = 0 1 1 1 1 1 | sum_b[2,3,4,5,6] % 2 = 1 で == 1(a[0]) なので 0
n = int(input())
aaa = list(map(int, input().split(' ')))
aaa = [0] + aaa
bbb = [0] * len(aaa)
ans_count = 0
ans = []
for i in range(n, 0, -1):
    hoge = 0
    for j in range(i+i, n, i):
        hoge += bbb[j]
    bbb[i] = 0 if (hoge % 2) == aaa[i] else 1
    if bbb[i] == 1:
        ans_count += 1
        ans.append(i)
    
print(ans_count)
if ans:
    print(' '.join(map(str, ans)))

Submission status: Wrong Answer

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

for i in range(N):
    ai = A[i]
    if ai == 0:
        print(0)
        exit(0)
    else:
        print(1)
        print(i)
        exit(0)
print(-1)

Submission status: Wrong Answer

Solution code:
import sys
from heapq import heappush, heappop
#input = sys.stdin.readline

def main():
    n=int(input())
    a=list(map(int,input().split()))
    b=[0]*n
    m=0
    for i in range(n-1,-1,-1):
        k=n//(i+1)
        if k==1:
            b[i]=a[i]
        else:
            s=0
            for j in range(2,k+1):
                s+=b[i*j]
            b[i]=(s+a[i])%2
    ans=[]
    for i in range(n):
        if b[i]==1:
            ans.append(i+1)
    print(sum(b))
    if len(ans)!=0:
        print(' '.join(map(str,ans)))
    
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
N = int(input())
a = [0] + [int(x) for x in input().split()]

ans = [0 for _ in range(N+1)]
for i in reversed(range(1,N+1)) :
    temp = 0
    for j in range(N//i) :
        temp += ans[(j+1) * i]
    ans[i] = a[i] - temp%2

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

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int,input().split()))
b = [0]*N
bina = 0
M = 0
for i in reversed(range(1,N+1)):
    next_num = i+i
    while(next_num <= N):
        bina ^= b[next_num-1]
        next_num += i
    b[i-1] = bina*a[i-1]
    bina = 0
M = sum(b)
print(M)
for i in range(N):
    if(b[i] == 1):
        print(i+1)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int,input().split()))
b = [0]*N
bina = 0
M = 0
for i in reversed(range(1,N+1)):
    next_num = i+i
    while(next_num <= N):
        bina ^= a[next_num-1]
        next_num += i
    b[i-1] = bina*a[i-1]
    bina = 0
M = sum(b)
print(M)
for i in range(N):
    if(b[i] == 1):
        print(i+1)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int,input().split()))
b = [0]*N
bina = 0
M = 0
for i in reversed(range(1,N+1)):
    next_num = i
    while(next_num <= N):
        bina ^= a[next_num-1]
        next_num += i
    b[i-1] = bina*a[i-1]
    bina = 0
M = sum(b)
print(M)
for i in range(N):
    if(b[i] == 1):
        print(i+1)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int,input().split()))
b = []
bina = 0
M = 0
for i in reversed(range(N)):
    next_num = i+1
    while(next_num <= N):
        bina ^= a[next_num-1]
        next_num += (i+1)
    if(bina == 1):
        M += 1
        b.append(i+1)
        bina = 0
print(M)
print(" ".join(map(str,b)))

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int,input().split()))
b = []
bina = 0
M = 0
for i in reversed(range(N)):
    j = 1
    while((i+1)*j <= N):
        bina ^= a[(i+1)*j-1]
        j += 1
    if(bina == 1):
        M += 1
        b.append(i+1)
        bina = 0
print(M)
print(" ".join(map(str,b)))

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int,input().split()))
b = []
bina = 0
M = 0
for i in reversed(range(N)):
    j = 1
    while((i+1)*j < N):
        bina ^= a[(i+1)*j-1]
        j += 1
    if(bina == 1):
        M += 1
        b.append((i+1))
        bina = 0
print(M)
print(" ".join(map(str,b)))

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int,input().split()))
b = []
bina = 0
M = 0
for i in reversed(range(N)):
    j = 1
    while((i+1)*j < N):
        bina ^= a[(i+1)*j-1]
        j += 1
    if(bina == 1):
        M += 1
        b.append((i+1))
print(M)
print(" ".join(map(str,b)))

Submission status: Wrong Answer

Solution code:
import sys

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

print(sum(a))

for i in range(len(a)):
    if a[i]==1:
        sys.stdout.writelines(str(i+1)+' ')
print("")

Submission status: Wrong Answer

Solution code:
#python3

def main():
    n = int(input())
    a = [int(i) for i in input().split()]
    b = [0 for _ in range(n)]
    for i in reversed(range(1, n+1)):
        s = 0
        j = i + i
        while j <= n: 
            s ^= b[j-1]
            j += i
        b[i-1] = s^a[i-1]
    
    m = sum(b)
    print(m)
    for i in range(n):
        if b[i] == 1:
            if i == n-1:
                print(b[i])
            else:
                print(b[i], end=' ')
        
main()

Submission status: Wrong Answer

Solution code:
#python3

def main():
    n = int(input())
    a = [int(i) for i in input().split()]
    dp = [0 for _ in range(n)]
    for i in reversed(range(1, n+1)):
        #iの倍数を列挙する　 
        ov = []
        j = 1
        while i*j <= n:
            ov.append(i*j) 
            j += 1 

        s = 0
        for k in range(len(ov)):
            v = ov[k]
            s = s ^ dp[v-1]             
        dp[i-1] = s ^ a[i-1] 
    m = sum(dp)
    print(m) 
    for i in range(n):
        if dp[i] == 1:
            if i == n-1:
                print(dp[i])
            else:
                print(dp[i], end=' ')
main()

Submission status: Wrong Answer

Solution code:
#python3

def main():
    n = int(input())
    a = [int(i) for i in input().split()]
    dp = [0 for _ in range(n)]
    for i in range(1, n+1):
        #iの倍数を列挙する　 
        ov = []
        j = 1
        while i*j <= n:
            ov.append(i*j-1) 
            j += 1 

        s = 0
        for k in range(len(ov)):
            v = ov[k]
            s = s ^ dp[v]             
        dp[i-1] = s ^ a[i-1] 
    m = sum(dp)
    print(m) 
    for i in range(n):
        if dp[i]:
            if i == n-1:
                print(dp[i])
            else:
                print(dp[i], end=' ')
main()

Submission status: Wrong Answer

Solution code:
# import bisect
# from collections import Counter, defaultdict, deque, namedtuple
# import copy
# from heapq import heappush, heappop, heapify
# from fractions import gcd
# import itertools
# from operator import attrgetter, itemgetter
# import math

import sys

# import numpy as np

ipti = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)

def main():
    n = int(input())
    a = list(map(int,ipti().split()))
    ball = [0] * (n+1)

    for i in range(n, 0, -1):
        cnt = a[i-1]
        num = i
        while num < n:
            if ball[num] == 1:
                cnt += 1
            num += i
        if cnt % 2 == 1:
            ball[i] = 1

    res = []
    m = 0

    for i in range(1, n+1):
        if ball[i] == 1:
            res.append(i)
            m+=1
    if m > 0:
        print(m)
        print(*res)
    else:
        print(0)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
# import bisect
# from collections import Counter, defaultdict, deque, namedtuple
# import copy
# from heapq import heappush, heappop, heapify
# from fractions import gcd
# import itertools
# from operator import attrgetter, itemgetter
# import math

import sys

# import numpy as np

ipti = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)

def main():
    n = int(input())
    a = list(map(int,ipti().split()))
    ball = [0] * (n+1)

    for i in range(n, 0, -1):
        cnt = a[i-1]
        num = i
        while num < n:
            if ball[num] == 1:
                cnt += 1
            num += i
        if cnt % 2 == 1:
            ball[i] = 1

    res = []
    for i in range(1, n+1):
        if ball[i] == 1:
            res.append(i)
    if res:
        print(*res)
    else:
        print(0)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
# D
n = int(input())
a = list(map(int, input().split()))
ans = [0 for i in range(n+1)]
a.reverse()
for i,num in enumerate(a):
    sum_a = 0
    for j in range(0,(n-i),n+1):
        sum_a += ans[j]
    if sum_a%2 == 0:
        if num == 1:
            ans[n-i] = 1
    else:
        if num == 0:
            ans[n-i] = 1
sum_ans = 0
ansprint = []
for i,num in enumerate(ans):
    if num == 1:
        ansprint.append(i)
        sum_ans+=1
print(sum_ans)
print(*ansprint, sep=' ')

Submission status: Wrong Answer

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

for i in range(1,N+1)[::-1]:
    s = 0
    now = 0
    k = 2

    while True:
        now = i*k
        if now > N:
            break
        s += a[now]
        k += 1

    if s%2 == a[i]:
        ball[i] = 0
    else:
        ball[i] = 1

print(sum(ball))

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

Submission status: Wrong Answer

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

for i in range(1,N+1)[::-1]:
    s = 0
    now = 0
    k = 2

    while True:
        now = i*k
        if now > N:
            break
        s += a[now]
        k += 1

    if s%2 == a[i]:
        ball[i] = 0
    else:
        ball[i] = 1

print(sum(ball))

for i in range(N+1):
    if ball[i] == 1:
        print(i)

Submission status: Wrong Answer

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

def get_divisors(n):
  arr = set()
  for i in range(1,int(n**0.5)+1):
    if n % i == 0:
      arr.add(i)
      arr.add(n//i)
  return arr

cnt = [0]*n
div = set()
for i in range(n,0,-1):
  if a[i-1] != cnt[i-1]:
    div = get_divisors(i)
    for j in div:
      cnt[j-1] += 1
      cnt[j-1] %= 2
  else:
    cnt[i-1] = 0

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

print(sum(cnt))
if b: print(*b)

Submission status: Wrong Answer

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

def get_divisors(n):
  arr = set()
  for i in range(1,int(n**0.5)+1):
    if n % i == 0:
      arr.add(i)
      arr.add(n//i)
  return arr

cnt = [0]*n
for i in range(n,0,-1):
  if a[i-1] != cnt[i-1]:
    div = get_divisors(i)
    for j in div:
      cnt[j-1] += 1
      cnt[j-1] %= 2
  else:
    cnt[i-1] = 0

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

print(sum(cnt))
if b: print(*b)

Submission status: Wrong Answer

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

def get_divisors(n):
  arr = set()
  for i in range(1,int(n**0.5)+1):
    if n % i == 0:
      arr.add(i)
      arr.add(n//i)
  return arr

cnt = [0]*n
for i in range(n,0,-1):
  div = get_divisors(i)
  if a[i-1]%2 != cnt[i-1]%2:
    for j in div:
      cnt[j-1] += 1
      cnt[j-1] %= 2

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

print(sum(cnt))
if b: print(*b)

Submission status: Wrong Answer

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

for i in range(n,0,-1):
    
    k = 1
    count = 0
    while k*i <= n:
        count += ans[k*i]
        k += 1
    if count%2 != l[i-1]:
        ans[i] = 1
print(sum(ans))
print(*ans[1:])

Submission status: Wrong Answer

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

for i in range(n,0,-1):
    
    k = 1
    count = 0
    while k*i <= n:
        count += ans[k*i]
        k += 1
    if count%2 != l[i-1]:
        ans[i] = 1
print(sum(ans))
print("1 "*sum(ans))

Submission status: Wrong Answer

Solution code:
n = int(input())
l = list(map(int,input().split()))
ans = [0]*(n//2+1)+l[n//2:]

for i in range(n//2,0,-1):
    
    k = 2
    count = 0
    while k*i <= n:
        count += ans[k*i]
        k += 1
    if count%2 != l[i-1]:
        ans[i] = 1
print(sum(ans))
print("1 "*sum(ans))

Submission status: Wrong Answer

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

check = [0] * N

for i in reversed(range(1, N + 1)):
    x = i
    total = 0
    while x <= N:
        if check[x - 1] == 1:
            total += 1
        x += i
    if total % 2 != A[i - 1]:
        check[i - 1] = 1

M = check.count(1)

print(M)
for i in range(M):
    if check[i] == 1:
        print(i + 1)

Submission status: Wrong Answer

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

#    print(i, list(range(2 * i, n+1, i)))

    #for j in range(2 * i, n+1, i):