Problem:


Score : 400 points

Problem Statement

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

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

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

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

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

Constraints

All values in input are integers.

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

a_i is 0 or 1.

Input

Input is given from Standard Input in the following format:

N
a_1 a_2 ... a_N

Output

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

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

M
b_1 b_2 ... b_M

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

Sample Input 1

3
1 0 0

Sample Output 1

1
1

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

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

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

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

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

Sample Input 2

5
0 0 0 0 0

Sample Output 2

0

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



Sample input:
3
1 0 0


Sample output:
1
1

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
c = [0]
d = c + a
s = [0 for i in range(n + 1)]

for i in range(n, 0, -1):
    w = 0
    for j in range(2 * i, n + 1, i):
        w ^= s[j]
    s[i] = w ^ d[i]

print(sum(s))
for i in range(1, n + 1):
    if s[i]:
        print(s[i],end=' ')

Submission status: Wrong Answer

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

C=[]
for i in range(int(n**0.5)):
    if B[i]%2==i+1:
        C.append(i+1)

if len(C)==0:print(0);exit()
print(1)
print(*C)

Submission status: Wrong Answer

Solution code:
# 2019-11-15 14:12:24(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
# from functools import reduce
# import operator as op
# import re
# from scipy.misc import comb # float
# import numpy as np 

def main():
    n, *a = [int(x) for x in sys.stdin.read().split()]
    a = [None] + a

    in_or_not = [0 for _ in range(n+1)]
    for i in range(1, n+1):
        count = 0
        for j in range(2 * i, n+1, i):
            count += in_or_not[j]
        if a[i] == 1:
            if count % 2 == 0:
                in_or_not[i] = 1
        else:
            if count % 2 == 1:
                in_or_not[i] = 1
    

    print(in_or_not.count(1))
    for i in range(1, n+1):
        if in_or_not[i] == 1:
            print(i, end=' ')




if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [0] + list(map(int, input().split()))
ans = [0] * (n+1)
for i in range(n,0,-1):
  SUM = 0
  for j in range(i,n+1,i):
    SUM += ans[j]
  ans[i] = (SUM + a[i]) % 2
m = 0
b = []
for key,i in enumerate(a):
  if i:
    m += 1
    b.append(key)
print(m)
print(*b)

Submission status: Wrong Answer

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

x = N // 2

ans = []
for i in range(x, N):
    b[i] = A[i]
for i in range(x+1, 0, -1):
    s = b[i-1::i]
    b[i-1] = 0 if sum(s) % 2 == A[i-1] else 1
    ans = [str(i+1) for i, x in enumerate(b) if x == 1]
print(len(ans))
if ans:
    print(' '.join(ans))

Submission status: Wrong Answer

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


# 後ろから判定していく
for i in range(n):
    c = 0
    for j in range(n - i - 1, n, n - i):
        # print(j, end=" ")
        if arr[j] == 1:
            c += 1
    # print()
    # print("i={}, c={}".format(n - i - 1, c))
    if arr[n - i - 1] != c % 2:
        print("-1")
        exit()

# いけるパターンは、与えられた配列の1が立っているところ
print(sum(arr))  # めんどいのでこれでいいや
for i, v in enumerate(arr):
    if v == 1:
        print(i + 1)

Submission status: Wrong Answer

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

# 後ろから判定していく
for i in range(n):
    c = 0
    for j in range(i, n, n - i):
        if arr[j] == 1:
            c += 1
    if arr[i] != c % 2:
        print("-1")
        exit()

# いけるパターンは、与えられた配列の1が立っているところ
print(sum(arr))  # めんどいのでこれでいいや
for i, v in enumerate(arr):
    if v == 1:
        print(i + 1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#ABC134 D - Preparing Boxes
N = int(input())
A = list(map(int,input().split()))
B = []
T = [0]*(N+1)

for i in range(N,0,-1):
    total = 0
    v = i
    while v <= N:
        total += T[v]
        v += i
    if total%2 != A[i-1]:
        T[i-1]=1
        B.append(i)

B.sort()
if len(B)>0:
    print(len(B))
    print(*B)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
#ABC134 D - Preparing Boxes
N = int(input())
A = list(map(int,input().split()))
B = []
total = 0
for i in range(N,0,-1):
    if A[i-1]!=total%2:
        total+=1
        B.append(i)

B.sort()
if len(B)>0:
    print(len(B))
    print(*B)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
#ABC134 D - Preparing Boxes
N = int(input())
A = list(map(int,input().split()))
B = []
for i in range(N,0,-1):
    if A[i-1]==1:
        B.append(i)

B.sort()
if len(B)>0:
    print(len(B))
    print(*B)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
import math
import bisect

n = int(input())
a = list(map(int, input().split()))
f = 0
cnt = 0
ans = []

for i in range(n-1,-1,-1):
    if a[i] == 1:
        cnt += 1
        ans.append(i+1)
        ri = math.sqrt(i)
        k = int(ri) + 1
        for j in range(2,k):
            if i % j == 0:
                f = 1
        else:
            if f == 1:
                break
    else:
        pass

if f == 1:
    print(-1)
else:
    print(cnt)
    if ans:
        print(' '.join(map(str,ans)))

Submission status: Wrong Answer

Solution code:
import math
import bisect

n = int(input())
a = list(map(int, input().split()))
f = 0
cnt = 0
ans = []

for i in range(n-1,-1,-1):
    if a[i] == 1:
        cnt += 1
        ans.append(i+1)
        ri = math.sqrt(i)
        k = bisect.bisect(a,ri)
        for j in range(2,k):
            if i % j == 0:
                break
        else:
            f = 1
            break
    else:
        pass

if f == 1:
    print(-1)
else:
    print(cnt)
    if ans:
        print(' '.join(map(str,ans)))

Submission status: Wrong Answer

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


def main():
    N = int(input())
    a = list(map(int, input().strip().split()))
    ans = [0] * N

    for i, a_r in enumerate(a[::-1]):
        j = N - i - 1
        count = 0
        now = j+1
        while now <= N:
            count += ans[now-1]
            now += j+1

        if a_r == 0:
            if count % 2 == 1:
                ans[j] = 1
        else:
            if count % 2 == 0:
                ans[j] = 1

    output = ""
    count = 0
    for i, b in enumerate(ans):
        if b == 1:
            output += str(a[i]) + " "
            count += 1
    print(count)
    if count != 0:
        print(output[:-1])


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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


def main():
    N = int(input())
    a = list(map(int, input().strip().split()))
    ans = [0] * N
    for i, a_r in enumerate(a[::-1]):
        j = N - i - 1
        count = 0
        now = j+1
        while now <= N:
            count += ans[now-1]
            now += j+1
        if a_r == 0:
            if count % 2 == 1:
                ans[j] = 1
        else:
            if count % 2 == 0:
                ans[j] = 1
    output = ""
    count = 0
    for i, b in enumerate(ans):
        if b == 1:
            output += str(a[i]) + " "
            count += 1
    print(count)
    if count != 0:
        print(output)
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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


def main():
    N = int(input())
    a = list(map(int, input().strip().split()))
    ans = [0] * N
    for i, a_r in enumerate(a[::-1]):
        j = N - i - 1
        count = 0
        now = j+1
        while now <= N:
            count += ans[now-1]
            now += j+1
        if a_r + count % 2 == 1:
            ans[j] = 1

    output = ""
    count = 0
    for i, b in enumerate(ans):
        if b == 1:
            output += str(a[i]) + " "
            count += 1
    print(count)
    if count != 0:
        print(output)
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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


def main():
    N = int(input())
    a = list(map(int, input().strip().split()))
    ans = [0] * N
    for i, a_r in enumerate(a[::-1]):
        j = N - i - 1
        count = 0
        now = j+1
        while now <= N:
            count += ans[j]
            now += j+1
        if a_r + count % 2 == 1:
            ans[j] = 1
    
    output = ""
    count = 0
    for i, b in enumerate(ans):
        if b == 1:
            output += str(a[i]) + " "
            count += 1
    print(count)
    if count != 0:
        print(output)
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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


def main():
    N = int(input())
    a = list(map(int, input().strip().split()))
    ans = [0] * N
    for i, a_r in enumerate(a[::-1]):
        j = N - i - 1
        count = 0
        now = j+1
        while now <= N:
            count += ans[j-1]
            now += j+1
        if a_r + count % 2 == 1:
            ans[j] = 1
    output = ""
    count = 0
    for i, b in enumerate(ans):
        if b == 1:
            output += str(a[i]) + " "
            count += 1
    print(count)
    if count != 0:
        print(output)
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def solve():
    N, *a_l = map(int, open(0).read().split())
    a_l = [0] + a_l
    b_l = [0] * (N + 1)

    for i in range(N, 0, -1):
        b_l[i] = sum(a_l[i::i]) % 2
    
    output_l = [i for i, x in enumerate(b_l) if x]

    print(len(output_l))
    if len(output_l) != 0:
        print(' '.join(map(str, output_l)))


if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

Solution code:
def solve():
    N, *a_l = map(int, open(0).read().split())
    m = 0
    b_l = [0] * N
    output_l = []

    for i in range(N-1, -1, -1):
        multiple_sum = 0
        for j in range(1, N):
            if i * j > N - 1:
                break
            else:
                multiple_sum += b_l[i * j]
        if multiple_sum % 2 != a_l[i]:
            b_l[i] = 1
            m += 1
            output_l.append(i+1)

    print(m)
    if m != 0:
        print(' '.join(map(str, output_l)))


if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

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

c = []
for i in range(1,n):
    if ((i+1)==2 or (i+1)//2==1):
        if a[i] == 1:
            c.append((i+1))
if len(c)//2!=a[0]:
    c.append(1)

print(len(c))
print(' '.join(map(str,c)))

Submission status: Wrong Answer

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

c = []
for i in range(1,n):
    if (i==2 or i//2==1):
        if a[i] == 1:
            c.append(i)
if len(c)//2!=a[0]:
    c.append(1)

print(len(c))
print(' '.join(map(str,c)))

Submission status: Wrong Answer

Solution code:
#test
print(0)

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):
    tmp = a[i-1]
    for j in range(n//i+1,0,-1):##上から
        if j*i<=n:
            tmp+=ans[i*j-1]
    ans[i-1] = tmp%2

#print(ans)
m = sum(ans)
if m == 0:
    print(m)
else:
    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( )))
ans = [0]*n
for i in range(n,0,-1):
    tmp = a[i-1]
    for j in range(1,n//i+2):
        if j*i<=n:
            tmp+=ans[i*j-1]
    ans[i-1] = tmp%2

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

Submission status: Wrong Answer

Solution code:
def main():
    n=int(input())
    a = list(map(int,input().split()))
    if a==[0 for _ in range(n)]:
        print(0)
        return
    box=[0 for _ in range(n)]
    for i in range(n,0,-1):
        if n//i==1:
            box[i-1]=a[i-1]
        else:
            c=0
            for j in range((n//i)-1):
                c+=a[(j+2)*i-1]
            box[i-1]=(a[i-1]+c)%2
    print(sum(box))
    ans=[]
    for i in range(n):
        if box[i]==1:
            ans.append(str(i+1))
    print(' '.join(ans))

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!

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

ans_l = [0 for i in range(n)]
for i in reversed(range(n+1)):
    if i == 0:
        break
    now = 0
    for j in range(2,n+1):
        if j * i <= n:
            now += al[j*i-1]
        else:
            break
    if now%2 == al[i-1]:
        ans_l[i-1] = 0
    else:
        ans_l[i-1] = 1
        
print(sum(ans_l))
for idx,i in enumerate(ans_l):
    if i == 1:
        print(idx+1)

Submission status: Wrong Answer

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

b = [0]*(N+1)
ball_num = 0
ball_box = []
for i in reversed(range(N)):
    cnt = 0
    for j in range((i+1)*(i+1), N+1, i+1):
        cnt += b[j]
    if (cnt % 2) != a[i]:
        ball_box.append(i+1)
        ball_num += 1
        b[i+1] = 1

print(ball_num)
if ball_num != 0:
    print(*ball_box)

Submission status: Wrong Answer

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

b = [0]*(N+1)
ball_num = 0
ball_box = []
for i in reversed(range(N)):
    cnt = 0
    for j in range((i+1)*(i+1), N+1, i+1):
        cnt += b[j]
    if a[i] == 0:
        if (cnt % 2) == 0:
            continue
        else:
            ball_box.append(i+1)
            ball_num += 1
            b[i+1] = 1
    elif a[i] == 1:
        if (cnt % 2) == 0:
            ball_box.append(i+1)
            ball_num += 1
            b[i+1] = 1
        else:
            continue

print(ball_num)
if ball_num != 0:
    print(*ball_box)

Submission status: Wrong Answer

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

b = [0]*(N+1)
ball_num = 0
ball_box = []
for i in reversed(range(N)):
    cnt = 0
    for j in range((i+1)*(i+1), N+1, i+1):
        cnt += b[j]
    if a[i] == 0:
        if (cnt%2) == 0:
            continue
        else:
            ball_box.append(i+1)
            ball_num += 1
            b[i+1] = 1
    elif a[i] == 1:
        if (cnt%2) == 0:
            ball_box.append(i+1)
            ball_num += 1
            b[i+1] = 1
        else:
            continue

print(ball_num)
if ball_num != 0:
    print(*ball_box)

Submission status: Wrong Answer

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

def make_divisors(n, ar):
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            ar[i] += 1
            if i != n // i:
                ar[n//i] += 1

tmp = [0]*(N+1)
b = [0]*(N+1)
ball_num = 0
ball_box = []
for i in reversed(range(N)):
    cnt = 0
    for j in range((i+1)*(i+1), N+1, i+1):
        cnt += b[j]
    if a[i] == 0:
        if (cnt%2) == 0:
            continue
        else:
            ball_box.append(i+1)
            ball_num += 1
            b[i+1] = 1
    elif a[i] == 1:
        if (cnt%2) == 0:
            ball_box.append(i+1)
            ball_num += 1
            b[i+1] = 1
        else:
            continue

print(ball_num)
if ball_num != 0:
    print(*ball_box)

Submission status: Wrong Answer

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

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

def make_divisors(n, ar):
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            ar[i] += 1
            if i != n // i:
                ar[n//i] += 1

tmp = [0]*(N+1)
b = [0]*(N+1)
ball_num = 0
ball_box = []
for i in reversed(range(N)):
    cnt = 0
    for j in range((i+1)*(i+1), N+1, i+1):
        cnt += b[j]
    if a[i] == 0:
        if (cnt%2) == 0:
            continue
        else:
            ball_box.append(i+1)
            ball_num += 1
            b[i+1] = 1
    elif a[i] == 1:
        if (cnt%2) == 0:
            ball_box.append(i+1)
            ball_num += 1
            b[i+1] = 1
        else:
            b[i+1] = 1
            continue

print(ball_num)
if ball_num != 0:
    print(*ball_box)

Submission status: Wrong Answer

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

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

def make_divisors(n, ar):
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            ar[i] += 1
            if i != n // i:
                ar[n//i] += 1

tmp = [0]*(N+1)
b = [0]*(N+1)
ball_num = 0
ball_box = []
for i in reversed(range(N)):
    cnt = 0
    for j in range((i+1)*(i+1), N+1, i+1):
        cnt += b[j]
    if a[i] == 0:
        if (cnt%2) == 0:
            continue
        else:
            ball_box.append(i+1)
            ball_num += 1
            b[i+1] = 1
    elif a[i] == 1:
        if (cnt%2) == 0:
            ball_box.append(i+1)
            ball_num += 1
            b[i+1] = 1
        else:
            continue

print(ball_num)
if ball_num != 0:
    print(*ball_box)

Submission status: Wrong Answer

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

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

def make_divisors(n, ar):
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            ar[i] += 1
            if i != n // i:
                ar[n//i] += 1

tmp = [0]*(N+1)
b = [0]*(N+1)
ball_num = 0
ball_box = []
for i in reversed(range(N)):
    cnt = 0
    for j in range((i+1)*(i+1), N+1):
        cnt += b[j]
    if a[i] == 0:
        if (cnt%2) == 0:
            continue
        else:
            ball_box.append(i+1)
            ball_num += 1
            b[i+1] = 1
    elif a[i] == 1:
        if (cnt%2) == 0:
            ball_box.append(i+1)
            ball_num += 1
            b[i+1] = 1
        else:
            continue

print(ball_num)
if ball_num != 0:
    print(*ball_box)

Submission status: Wrong Answer

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

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

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


tmp = [0]*(N+1)
b = [0]*N
ball_num = 0
ball_box = []
for i in reversed(range(N)):
    if a[i] == 0:
        if (tmp[i+1]%2) == 0:
            continue
        else:
            ball_box.append(i+1)
            ball_num += 1
            val = make_divisors(i+1)
            for elms in val:
                tmp[elms] += 1
    elif a[i] == 1:
        if (tmp[i+1]%2) == 0:
            ball_box.append(i+1)
            ball_num += 1
            val = make_divisors(i+1)
            for elms in val:
                tmp[elms] += 1
        else:
            continue

print(ball_num)
if ball_num != 0:
    print(*ball_box)

Submission status: Wrong Answer

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

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)
    return divisors


tmp = [0]*(N+1)
b = [0]*N
for i in reversed(range(N)):
    if a[i] == 0:
        if (tmp[i+1]%2) == 0:
            b[i] = 0
        else:
            b[i] = 1
            val = make_divisors(i+1)
            for elms in val:
                tmp[elms] += 1
    elif a[i] == 1:
        if (tmp[i+1]%2) == 0:
            b[i] = 1
            val = make_divisors(i+1)
            for elms in val:
                tmp[elms] += 1
        else:
            b[i] = 0

print(b)

Submission status: Wrong Answer

Solution code:

N = int(input())
arr = input().split()
print(arr.count('1'))
for i in range(N):
  if arr[i] == '1':
    print(i+1, end = ' ')

Submission status: Wrong Answer

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

t = [0] * (N + 1)
for i in range(N, 0, -1):
    t[i] = (sum(t[2 * i:i]) % 2) ^ a[i - 1]

print(sum(t))
print(*[i for i in range(1, N + 1) if t[i] == 1])

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
cnt=[]
def divis(n):
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            a[i-1]^=1
            if i != n // i :
                ij=n//i
                a[ij-1]^=1
for i in reversed(range(n)):
    if a[i]==1:
        cnt.append(i+1)
        divis(i+1)
if len(cnt)>0:
    print(*cnt)
else:
    print(0)

Submission status: Wrong Answer

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

def divis(n):
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            a[i-1]^=1
            if i != n // i :
                ij=n//i
                a[ij-1]^=1

for i in reversed(range(n)):
    if a[i]==1:
        divis(i+1)

print(" ".join(map(str,a)))

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    n=int(input())
    A=['$']+list(map(int,input().split())) # 1-index
    ans=[0]*(n+1)
    for i in range(n,0,-1): # iを確定させたい
        parity=A[i]
        for j in range(2,n//i+1): # iの倍数のうち、i以外のものを全てみる
            parity+=ans[i*j]
        if(parity%2): ans[i]=1
    s=sum(i for i in range(1,n+1) if ans[i])
    print(s)
    if(s):
        print(*(i for i in range(1,n+1) if ans[i]))
resolve()

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    n=int(input())
    A=['$']+list(map(int,input().split())) # 1-index
    ans=[0]*(n+1)
    for i in range(n,0,-1): # iを確定させたい
        parity=A[i]
        for j in range(2,n//i+1): # iの倍数のうち、i以外のものを全てみる
            parity+=ans[i*j]
        if(parity): ans[i]=1
    s=sum(i for i in range(1,n+1) if ans[i])
    print(s)
    if(s):
        print(*(i for i in range(1,n+1) if ans[i]))
resolve()

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    n=int(input())
    A=['$']+list(map(int,input().split())) # 1-index
    ans=[0]*(n+1)
    for i in range(n,0,-1): # iを確定させたい
        parity=A[i]
        for j in range(2,n//i+1): # iの倍数のうち、i以外のものを全てみる
            parity+=A[i*j]
        if(parity): ans[i]=1
    s=sum(i for i in range(1,n+1) if ans[i])
    print(s)
    if(s):
        print(*(i for i in range(1,n+1) if ans[i]))
resolve()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [-1]+list( map(int, input().split()) )
b = [0]*(n+1)
res = 0
ary = []

for i in range(n, 0, -1):
    tmp = 0
    for j in range( 2*i, n+1, i ):
        tmp += b[j]
    if tmp != a[i]:
        res += 1
        b[i] = 1
for i in range(1, n+1):
    if b[i] == 1:
        ary.append(i)
print(res)
if res != 0:
    print(*ary)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [-1]+list( map(int, input().split()) )
b = [0]*(n+1)
res = 0
ary = []

for i in range(n, 0, -1):
    tmp = 0
    for j in range( 2*i, n+1, i ):
        tmp += b[j]
    if tmp != a[i]:
        res += 1
        b[i] = 1
        ary.append(i)
print(res)
if res != 0:
    print(*ary)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list( map(int, input().split()) )
a.insert(0,0)
count = [0]*(n+1)
res = 0
ary = []

for i in range(n, 0, -1):
    for j in range( 2*i, n+1, i ):
        count[i] += count[j]
    if count[i]%2 != a[i]:
        res += 1
        count[i] = 1
        ary.append(i)
print(res)
if res != 0:
    print(*ary)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list( map(int, input().split()) )
a.insert(0,0)
count = [0]*(n+1)
res = 0
ary = []

for i in range(n, 0, -1):
    for j in range( 2*i, n+1, i ):
        count[i] += count[j]
    if count[i]%2 != a[i]:
        res += 1
        ary.append(i)
        count[i] = ( count[i] % 2 + 1 ) % 2
print(res)
if res != 0:
    print(*ary)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list( map(int, input().split()) )
a.insert(0,0)
count = [0]*(n+1)
res = 0
ary = []

for i in range(n, 0, -1):
    for j in range( 2*i, n+1, i+1 ):
        count[i] += count[j]
    if count[i]%2 != a[i]:
        res += 1
        ary.append(i)
        count[i] = ( count[i] % 2 + 1 ) % 2
print(res)
if res != 0:
    print(*ary)

Submission status: Wrong Answer

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

ans=[]
for h in range(N+1):
    ans.append(0)

for i in reversed(range(1,N+1)):
    SUM=0
    q=N//i
    if q>=2:
        for j in range(2,q+1):
            SUM+=ans[i*j]
        if SUM!=A[i]:
            ans[i]=1
    else:
        ans[i]=A[i]

ANS=[]
count=0

for k in range(N):
    if ans[k]==1:
        ANS.append(k)
        count+=1

print(count)
print(*ANS)

Submission status: Wrong Answer

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

if sum(a) == 0:
    print(0)
    exit()

for i in range(1, n+1):
    if i == n:
        if a[0] == 1 and sum(b) % 2 == 0:
            b[0] = 1
            count += 1
        elif a[0] == 0 and sum(b) % 2 == 1:
            b[0] = 1
            count += 1
    elif a[n-i] == 1 and sum(b[(n-i-1)::(n-i)]) % 2 == 0:
        b[n-i] = 1
        count += 1
    elif a[n-i] == 0 and sum(b[(n-i-1)::(n-1)]) % 2 == 1:
        b[n-i] = 1
        count += 1


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

Submission status: Wrong Answer

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

if sum(a) == 0:
    print(0)
    exit()

for i in range(1, n+1):
    if a[n-i] == 1 and sum(b[::(n+1-i)]) % 2 == 0:
        b[n-i] = 1
        count += 1

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

Submission status: Wrong Answer

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

box = [0 for _ in range(n+1)]

for i in range(n, 0, -1):
    counter = 0
    for j in range(1, (n//i)+1):
        counter = box[j*i]
    if counter % 2 != a[i-1]:
        box[i] = 1
for i in range(1, n+1):
    counter = 0
    for j in range(1, (n//i)+1):
        counter += box[j*i]
    if counter%2 != a[i-1]:
        print(-1)
        sys.exit()
print(sum(box))
for i in range(1, n):
    if box[i] == 1:
        print(i)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
B = [0]*N
answer = []
for i in range(N, 0, -1):
  if A[i-1] == 1:
    count = 1
    number = 0
    while count*i < N:
      number += B[count*i-1]
      count+=1
    if number%2 == 0:
      B[i-1] = 1
      answer.append(i)
  else:
    count = 1
    number = 0
    while count*i < N:
      number +=B[count*i-1]
      count+=1
    if number%2==1:
      B[i-1] = 1
      answer.append(i)
print(B.count(1))
print(*answer)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
B = [0]*N
answer = []
for i in range(N, 0, -1):
  if A[i-1] == 1:
    count = 1
    number = 0
    while count*i < N:
      number += B[count*i]
      count+=1
    if number%2 == 0:
      B[i-1] = 1
      answer.append(i)
  else:
    count = 1
    number = 0
    while count*i < N:
      number +=B[count*i]
      count+=1
    if number%2==1:
      B[i-1] = 1
      answer.append(i)
print(B.count(1))
print(*answer)

Submission status: Wrong Answer

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

ball = [0]*N

for i in reversed(range(N)):
    Sum = 0
    x = 1
    while((i+1)*x <= N):
        Sum += a[(i+1)*x-1]
        x += 1

    ball[i] = (Sum+a[i]) % 2

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

Submission status: Wrong Answer

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

ball = [0]*N

for i in reversed(range(N)):
    Sum = 0
    x = 1
    while((i+1)*x <= N):
        Sum += a[(i+1)*x-1]
        x += 1

    ball[i] = Sum % 2

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

Submission status: Wrong Answer

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

ball = [0]*N

for i in reversed(range(N)):
    Sum = 0
    x = 1
    while((i+1)*x <= N):
        Sum += a[(i+1)*x-1]
        x += 1

    ball[i] = Sum

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

Submission status: Wrong Answer

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

ans = [0 for i in range(n)]
for num in range(n,0,-1):
  cnt = 0
  for nu in range(num-1,n,num):
    cnt += ans[nu]
  if lis[num-1] != cnt % 2:
    ans[num-1] = 1
  print(ans)
cnt1 = 0
for num in range(n):
  if ans[num] == 1:
    cnt1 += 1
print(cnt1)
for i in range(n):
  if ans[i] == 1:
    print(i+1,end = " ")

Submission status: Wrong Answer

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

ans = [0 for i in range(n)]
for num in range(n,0,-1):
  cnt = 0
  for nu in range(num-1,n,num):
    cnt += ans[nu]
  if lis[num-1] != cnt % 2:
    ans[num-1] = 1
last1 = 0
for num in range(n):
  if ans[num] == 1:
    last1 = num+1
print(last1)
for i in range(max(last1-1,0)):
  print(ans[i],end=" ")