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())
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(last1):
  print(ans[i],end=" ")

Submission status: Wrong Answer

Solution code:
N=int(input())
AL=list(map(int, input().split()))
L=[]
for i in range(N-1,0,-1):
    s=AL[i]
    for j in range((i+1)*2-1,N,i):
        s^=AL[j]
    AL[i]=s
    if AL[i]==1:
        L.append(i+1)
AL[0]^=(len(L)%2)
if AL[0]==1:
    L.append(1)
print(len(L))
if L:
    print(*L)

Submission status: Wrong Answer

Solution code:
N=int(input())
AL=list(map(int, input().split()))
L=[]
for i in range(N-1,0,-1):
    s=AL[i]
    for j in range(i*2,N,i):
        s^=AL[j]
    AL[i]=s
    if AL[i]==1:
        L.append(i+1)
AL[0]^=(len(L)%2)
if AL[0]==1:
    L.append(1)
print(len(L))
if L:
    print(*L)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
N=int(input())
A=list(map(int,input().split()))
"""
5
1 1 0 0 1
"""
count=0
ans=[]
hako=[0]*N
for i in range(N)[::-1]:
    all=0
    for j in range(i,N)[::i+1]:
        if i==j:
            continue
        all^=hako[j]
    if all==1:
        if A[i]==1:
            continue
        else:
            print(-1)
            exit()
    else:
        if A[i]==1:
            hako[i]=1
            count+=1
            ans.append(i+1)
        else:
            continue
ans.sort()
print(count)
print(*ans)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
N=int(input())
A=list(map(int,input().split()))
"""
5
1 1 0 0 1
"""
count=0
ans=[]
for i in range(1,N):
    all=0
    for j in range(i,N)[::i+1]:
        if i==j:
            continue
        all^=A[j]
    if all==1:
        print(-1)
        exit()
    else:
        if A[i]==1:
            count+=1
            ans.append(i+1)
        else:
            continue

ans.sort()

if count%2==0:
    if A[0]==1:
        print(count+1)
        print(1,*ans)
    else:
        print(count)
        print(*ans)
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
N=int(input())
A=list(map(int,input().split()))
#素数以外に1が存在してはいけない

count=0
ans=[]
for i in range(1,N)[::-1]:
    judge=0#i=1
    j=1
    while j*(i+1)-1<=N-1:
        judge=judge^A[j*(i+1)-1]
        j+=1
    
    if judge==0:
        if A[i]==0:
            pass
        else:
            print(-1)
            exit()
    else:
        if A[i]==1:
            count+=1
            ans.append(i+1)
        else:
            print(-1)
            exit()

ans.sort()

if len(ans)%2==1:
    print(-1)
else:
    if A[0]==1:
        print(count+1)
        print(1,*ans)
    else:
        print(count)
        print(*ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
 
answer_list = []
for i in range(N):
    counter = 0
    i_num = N - i
 
    # for j in range(i):
    #     j_num = i_num + j + 1
    #     if j_num // i_num == 0 and j_num in answer_list:
    #         counter += 1
    for answer in answer_list:
        if answer > i_num and answer // i_num == 0:
            counter += 1
    if counter % 2 == A[i_num - 1]:
        continue
    else:
        answer_list.append(i_num)
print(len(answer_list))
if answer_list:
    print(" ".join(map(str, answer_list)))

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
N=int(input())
A=list(map(int,input().split()))
#素数以外に1が存在してはいけない

def hurui(n):
    search=[True for i in range(n+1)]
    for i in range(2,n+1):
        if search[i-1]:
            j=2
            while j*i<=n:
                search[j*i-1]=False
                j+=1
        if i>n**0.5:
            break
    prime = [ i for i in range(1, n+1) if search[i-1]]
    prime.pop(0)
    return prime

prime=hurui(N)

judge=0
count=0
ans=[]
for i in range(1,N):
    if A[i]==1:
        if (i+1) in prime:
            judge=judge^A[i]
            count+=1
            ans.append(i+1)
        else:
            print(-1)
            exit()
if A[0]==0:
    if judge==0:
        print(count)
        print(*ans)
    else:
        print(-1)
else:
    if judge==0:
        print(count+1)
        print(1,*ans)
    else:
        print(-1)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
flag = [-1] * (N+1)
answer_list = []
for i in range(N):
    counter = 0
    i_num = N - i
    for j in range(i_num, N+1, i_num):
        if j == i_num:
            continue
        else:
            if flag[j] == 1:
                counter += 1
    if counter // 2 == A[i_num - 1]:
        flag[i_num] = 0
    else:
        flag[i_num] = 1
        answer_list.append(i_num)
print(len(answer_list))
if answer_list:
    print(" ".join(map(str, answer_list)))

Submission status: Wrong Answer

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

answer_list = []
for i in range(N):
    counter = 0
    i_num = N - i
    for j in range(i_num, N+1, i_num):
        if j in answer_list:
            counter += 1
    if counter // 2 == A[i_num - 1]:
        continue
    else:
        answer_list.append(i_num)
print(len(answer_list))
if answer_list:
    print(" ".join(map(str, answer_list)))

Submission status: Wrong Answer

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

answer_list = []
for i in range(N):
    counter = 0
    i_num = N - i

    # for j in range(i):
    j = 0
    while (i_num * j) < N:
        if (i_num * j)  in answer_list:
            counter += 1
        j += 1
    # for answer in answer_list:
    #     if answer > i_num and answer // i_num == 0:
    #         counter += 1
    if counter // 2 == A[i_num - 1]:
        continue
    else:
        answer_list.append(i_num)
print(len(answer_list))
if answer_list:
    print(" ".join(map(str, answer_list)))

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
N=int(input())
A=list(map(int,input().split()))

for i in range(N//2)[::-1]:#2倍が存在できるまで数字を落とした
    temp=0
    for j in range(i,N)[::i+1]:#倍数のもの
        temp=temp^A[j]
    if temp!=A[i]:
        print(-1)
        exit()

count=0
ans=[]
for index,item in enumerate(A):
    if item==1:
        ans.append(index+1)
        count+=1
print(count)
print(*ans)

Submission status: Wrong Answer

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

answer_list = []
for i in range(N):
    counter = 0
    i_num = N - i

    # for j in range(i):
    #     j_num = i_num + j + 1
    #     if j_num // i_num == 0 and j_num in answer_list:
    #         counter += 1
    for answer in answer_list:
        if answer > i_num and answer // i_num == 0:
            counter += 1
    if counter // 2 == A[i_num - 1]:
        continue
    else:
        answer_list.append(i_num)
print(len(answer_list))
if answer_list:
    print(" ".join(map(str, answer_list)))

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
N=int(input())
A=list(map(int,input().split()))

count=0
ans=[]
for index,item in enumerate(A):
    if item==1:
        count+=1
        ans.append(index+1)
        
print(count)
print(*ans)

Submission status: Wrong Answer

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

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

# 最初が0から始まる場合
a_list = [0] + a_list
b_list = [0] * (N + 1)
# インデックスがずれるのがややこしいので、
# b_list[0]は欠番として1始まりで考えていく

for i in range(N):
    # 大きい方から決めていく
    idx = N - i
    total = 0
    for j, b in enumerate(b_list[idx - 1 : N : idx]):
        # idx + 1の倍数のボールの個数を数える
        if j == 0:
            continue
        total += b

    if idx >= 2:
        if total % idx != a_list[idx]:
            b_list[idx] = 1
    else:
        b_list[1] = a_list[1]

idx_list = [str(i) for i, b in enumerate(b_list) if b == 1]
ans = sum(b_list[1:])
print(ans)
if ans != 0:
    print(" ".join(idx_list))

Submission status: Wrong Answer

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

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

# 最初が0から始まる場合
a_list = [0] + a_list
b_list = [0] * (N + 1)
# インデックスがずれるのがややこしいので、
# b_list[0]は欠番として1始まりで考えていく

for i in range(N):
    # 大きい方から決めていく
    idx = N - i
    total = 0
    for j, b in enumerate(b_list[::idx]):
        # idx + 1の倍数のボールの個数を数える
        if j == 0:
            continue
        total += b

    if idx >= 2:
        if total % idx != a_list[idx]:
            b_list[idx] = 1
    else:
        b_list[1] = a_list[1]

idx_list = [str(i) for i, b in enumerate(b_list) if b == 1]
ans = sum(b_list[1:])
print(ans)
if ans != 0:
    print(" ".join(idx_list))

Submission status: Wrong Answer

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

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

# 最初が0から始まる場合
a_list = [0] + a_list
b_list = [0] * (N + 1)
# インデックスがずれるのがややこしいので、
# b_list[0]は欠番として1始まりで考えていく

for i in range(N):
    # 大きい方から決めていく
    idx = N - i
    total = 0
    for j, b in enumerate(b_list[::idx]):
        # idx + 1の倍数のボールの個数を数える
        if j == 0:
            continue
        total += b

    if idx != 1:
        if total % idx != a_list[idx]:
            b_list[idx] = 1
    else:
        b_list[idx] = a_list[1]

idx_list = [str(i) for i, b in enumerate(b_list) if b == 1]
ans = sum(b_list[1:])
print(ans)
if ans != 0:
    print(" ".join(idx_list))

Submission status: Wrong Answer

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

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

# 最初が0から始まる場合
a_list = [0] + a_list
b_list = [0] * (N + 1)
# インデックスがずれるのがややこしいので、
# b_list[0]は欠番として1始まりで考えていく

for i in range(N):
    # 大きい方から決めていく
    idx = N - i
    total = 0
    for j, b in enumerate(b_list[::idx]):
        # idx + 1の倍数のボールの個数を数える
        if j == 0:
            continue
        total += b

    if total % idx != a_list[idx]:
        b_list[idx] = 1

idx_list = [str(i) for i, b in enumerate(b_list) if b == 1]
ans = sum(b_list[1:])
print(ans)
if ans != 0:
    print(" ".join(idx_list))

Submission status: Wrong Answer

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

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

# 最初が0から始まる場合
a_list = [0] + a_list
b_list = [0] * (N + 1)
# インデックスがずれるのがややこしいので、
# b_list[0]は欠番として1始まりで考えていく

for i in range(N):
    # 大きい方から決めていく
    idx = N - i
    total = 0
    for j, b in enumerate(b_list[::idx]):
        # idx + 1の倍数のボールの個数を数える
        if j == 0:
            continue
        total += b

    if total % idx != a_list[idx]:
        b_list[idx] = 1

idx_list = [str(i) for i, b in enumerate(b_list) if b == 1]
ans = sum(b_list[1:])
print(ans)
print(" ".join(idx_list))

Submission status: Wrong Answer

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

1
N = int(input().split()[0])
a_list = list(map(int, input().split()))

# 最初が0から始まる場合
b_list = [0] * N
b_list[-1] = a_list[-1]

for i in range(N):
    # 大きい方から決めていく
    idx = N - (i + 1)
    total = 0
    for j, bj in enumerate(b_list[:: idx + 1]):
        # idx + 1の倍数のボールの個数を数える
        total += b_list[j]

    if total % (idx + 1) != a_list[idx]:
        b_list[idx] = 1

idx_list = [str(i + 1) for i, b in enumerate(b_list) if b == 1]
ans = sum(b_list)
print(ans)
print(" ".join(idx_list))

Submission status: Wrong Answer

Solution code:
import bisect

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

    M = 0

    for i in range(N - 1, 0, -1):
        if i > N / 2:
            if a[i] == 1:
                b.append(i)
                M += 1
        else:
            num = i
            cnt = 0
            j = 2
            while i * j < N:
                num = i * j
                cnt += a[num]
                j += 1
            if cnt % 2 == 0 and a[i] != 0:
                b.append(i)
                M += 1
            elif a[i] == 0:
                b.append(i)
                M += 1
    
    print(M)
    print(*b)
    
    


if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

Solution code:
def sum_mulIndex(m, n, c):
  count, i = 0, 2
  while m*i <= n:
    count += c[m*i-1]
    i += 1
  return count

n = int(input())
a = list(map(int, input().split()))
c = [0]*n
s = []
q = [i+1 for i in range(n)]
for i in range(n):
  for j in range(n//(i+2), n//(i+1)):
    c[j] = sum_mulIndex(j+1, n, c) ^ a[j]
    if c[j]:
      s.append(j+1)

print(sum(c))
for i in s:
  print(i, end=' ')

Submission status: Wrong Answer

Solution code:
def sum_mulIndex(m, n, c):
  count, i = 0, 2
  while m*i <= n:
    count += c[m*i-1]
    i += 1
  return count

n = int(input())
a = list(map(int, input().split()))
c = [0]*n
s = set()
q = [i+1 for i in range(n)]
for i in range(n):
  for j in range(n//(i+2), n//(i+1)):
    c[j] = sum_mulIndex(j+1, n, c) ^ a[j]
    if c[j]:
      s.add(j+1)

print(sum(c))
for i in s:
  print(i, end=' ')

Submission status: Wrong Answer

Solution code:
import math

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

for i in range(n-1):
  ptr = n - 1 - i
  if a[ptr] % 2 == 1:
    a[0] += 1
    for j in range(2, int(math.sqrt(ptr+1))+1):
      if (ptr + 1) % j == 0:
        a[j-1] += 1
        a[(ptr + 1) // j - 1] += 1
      
cnt = 0
que = []
for  i in range(n):
  if a[i] % 2 == 1:
    cnt += 1
    que.append(i+1)

print(cnt)
if cnt > 0:
  print(' '.join(map(str, que)))

Submission status: Wrong Answer

Solution code:
import math

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

for i in range(n-1):
  ptr = n - 1 - i
  if a[ptr] % 2 == 1:
    for j in range(1, int(math.sqrt(ptr+1))+1):
      if (ptr + 1) % j == 0:
        a[j-1] += 1
      
cnt = 0
que = []
for  i in range(n):
  if a[i] % 2 == 1:
    cnt += 1
    que.append(i+1)

print(cnt)
if cnt > 0:
  print(' '.join(map(str, que)))

Submission status: Wrong Answer

Solution code:
import math

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

for i in range(n):
  ptr = n - 1 - i
  if a[ptr] % 2 == 1:
    for j in range(1, int(math.sqrt(ptr+1))+1):
      if (ptr + 1) % j == 0:
        a[j-1] += 1
      
cnt = 0
que = []
for  i in range(n):
  if a[i] % 2 == 1:
    cnt += 1
    que.append(i+1)

print(cnt)
if cnt > 0:
  print(' '.join(map(str, que)))

Submission status: Wrong Answer

Solution code:
import math

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

for i in range(n):
  ptr = n - 1 - i
  if a[ptr] % 2 == 1:
    for j in range(1, int(math.sqrt(ptr+2))+1):
      if (ptr + 1) % j == 0:
        a[j-1] += 1
      
cnt = 0
que = []
for  i in range(n):
  if a[i]:
    cnt += 1
    que.append(i+1)

print(cnt)
if cnt > 0:
  print(' '.join(map(str, que)))

Submission status: Wrong Answer

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

N = int(input())
*A, = map(int, input().split())
B = [0 for _ in range(N)]
for i in reversed(range(N)):
    B[i] = A[i]
    if A[i] == 1:
        for d in divisors(i):
            A[d] ^= 1
ans = [i for i, b in enumerate(B, 1) if b != 0]
print(len(ans))
print(*ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

b=[0]*(N+1)
M=0

for i in range(N,0,-1):
    cnt = 0

    for j in range(i+i,N+1,i):
        if b[j] == 1:
            cnt += 1

    if a[i-1]==1 and cnt%2==0:
        b[i]=1
        M+=1

print(M)
for i in range(1,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)
M=0

for i in range(N,0,-1):
    cnt = 0
    temp = i

    while temp + i <= N:
        if b[temp + i] == 1:
            cnt += 1
        temp += i
    if a[i-1]==1 and cnt%2==0:
        b[i]=1
        M+=1

print(M)
for i in range(1,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)
M=0

for i in range(N,0,-1):
    if a[i-1]==1:
        cnt=0
        temp=i
        while temp+i<=N:
            if b[temp+i]==1:
                cnt+=1
            temp+=i
        if cnt%2==0:
            b[i]=1
            M+=1

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

Submission status: Wrong Answer

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

b = [0] * N
M = 0
ans = []
for i in range(N, 0, -1):
    count = a[i-1]
    x = 2
    while x * i <= N:
        count += b[i-1]
        x += 1
    if count % 2 == 1:
        b[i-1] = 1
        M += 1
        ans.append(i)


print(M)
print(*ans)

Submission status: Wrong Answer

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

# 分かりやすくするために一番目はb[1]としたい
b = [0] * (N + 1)
for i in reversed(range(1, N + 1)):
    if sum(b[i::i]) % 2 != a[i]:
        b[i] = 1

if a.count(1) == -1:
    print(0)
else:
    print(a.count(1))
    print(' '.join(map(str, [i for i, x in enumerate(a) if x == 1])))

Submission status: Wrong Answer

Solution code:
N=int(input())
a=list(map(int,input().split()))
b=[0]*N
for i in reversed(range(N)):
  k= N // (i+1)
  tmp=0
  for j in range(1,k):
    tmp+=b[i*(j+1)]
  b[i]=abs((tmp%2)-a[i])
M=sum(b)
ans=[]
for i in range(N):
  if b[i]==1:
    ans.append(i+1)
print(M)
print(" ".join(map(str,ans)))

Submission status: Wrong Answer

Solution code:
N=int(input())
a=list(map(int,input().split()))
b=[0]*N
for i in reversed(range(N)):
  k= N // (i+1)
  tmp=0
  for j in range(1,k):
    tmp+=b[i*(j+1)]
  b[i]=(tmp%2)-a[i]
M=sum(b)
ans=[]
for i in range(N):
  if b[i]==1:
    ans.append(i+1)
print(M)
print(" ".join(map(str,ans)))

Submission status: Wrong Answer

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


ans = [0 for _ in range(N + 1)]
out = []
for idx in range(N, 0, -1):
	count = 0
	rep = 1
	while(idx * rep < N):
		count += ans[idx * rep]
		rep += 1
		
	if A[idx] != count % 2:
		ans[idx] = 1
		out.append(idx)

print(len(out))
if(len(out)>0):
	print(" ".join(map(str, out)))

Submission status: Wrong Answer

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


ans = []
for idx in range(N, 0, -1):
	if(idx * 2 < N):
		if A[idx] != A[2*idx]:
			ans.append(idx)
	else:
		if(A[idx] == 1):
			ans.append(idx)

print(len(ans))
if(len(ans)>0):
	print(" ".join(map(str, ans)))

Submission status: Wrong Answer

Solution code:
N=int(input())
a=list(map(int,input().split()))
b=[0]*N
for i in reversed(range(N)):
  k= N // (i+1)
  tmp=0
  for j in range(1,k):
    tmp+=b[i*(j+1)]
  b[i]=a[i]-(tmp%2)
M=sum(b)
ans=[]
for i in range(N):
  if b[i]==1:
    ans.append(i+1)
print(M)
print(" ".join(map(str,ans)))

Submission status: Wrong Answer

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


li=[0]*(n+1)
ans=[]
for i in range(n,0,-1):
    if a[i-1]==1:
        if sum(li[i::i])%2==0:
            ans.append(i)
    else:
        if sum(li[i::i])%2==1:
            ans.append(i)

print(len(ans))
print(*ans)

Submission status: Wrong Answer

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


li=[0]*(n+1)
ans=[]
for i in range(n,0,-1):
    if a[i-1]==1:
        if sum(li[i::i])%2==0:
            ans.append(i)
        else:
            print(-1)
            exit()
    else:
        if sum(li[i::i])%2==1:
            ans.append(i)
        else:
            print(-1)
            exit()

print(len(li))
print(*li)

Submission status: Wrong Answer

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


li=[]
for i in range(n,0,-1):
    if a[i-1]==1:
        if sum(li[i::i])%2==0:
            li.append(i)
        else:
            print(-1)
            exit()
    else:
        if sum(li[i::i])%2==1:
            li.append(i)
        else:
            print(-1)
            exit()

if li:
    print(len(li))
    print(*li)
else:
    print(0)

Submission status: Wrong Answer

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


li=[]
for i in range(n,0,-1):
    if a[i-1]==1:
        if sum(li[i::i])%2==0:
            li.append(i)
    else:
        if sum(li[i::i])%2==1:
            li.append(i)

if li:
    print(len(li))
    print(*li)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
N = int(input())
al = list(map(int, input().split()))
al.reverse()
nlr = [0 for _ in range(0, N)]
for i in range(0, N):
  index = N - i
  multiple_sum = sum(nlr[index::index])
  nlr[i] = 0 if al[i] == (multiple_sum % 2) else 1
      
nl = nlr[::-1]
print(sum(nl))
for i, has_ball in enumerate(nl, start=1):
  if has_ball == 1:
    print(i)

Submission status: Wrong Answer

Solution code:
N = int(input())
al = list(map(int, input().split()))
al.reverse()
nlr = [0 for _ in range(0, N)]
for i in range(0, N):
  if al[i] == 1:
    nlr[i] = 1
  else:
    index = N - i
    multiple_sum = sum(nlr[index::index])
    if multiple_sum % 2 == 1:
      nlr[i] = 1
    else:
      nlr[i] = 0
      
nl = nlr[::-1]
print(sum(nl))
for i, has_ball in enumerate(nl, start=1):
  if has_ball == 1:
    print(i)

Submission status: Wrong Answer

Solution code:
N = int(input())
al = list(map(int, input().split()))
al.reverse()
nlr = [0 for _ in range(0, N)]
for i in range(0, N):
  if al[i] == 1:
    nlr[i] = 1
  else:
    index = N - i
    multiple_sum = sum(filter(lambda x: x % index == 0, al[:i]))
    if multiple_sum == 1:
      nlr[i] = 1
    else:
      nlr[i] = 0
nlr.reverse()
print(sum(nlr))
for i, has_ball in enumerate(nlr, start=1):
  if has_ball == 1:
    print(i)

Submission status: Wrong Answer

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

    B = [0] * (N+1)

    for i in range(N,0,-1):
        tmp = 0
        for j in range(i,N,i):
            tmp ^= B[j]
        B[i] = tmp^A[i]

    cnt = 0
    ans = []
    for i in range(1,N+1):
        if B[i] == 1:
            cnt += 1
            ans.append(i)

    print(cnt)
    print(*ans)

main()

Submission status: Wrong Answer

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

    B = [0] * (N+1)

    for i in range(N,0,-1):
        tmp = 0
        for j in range(i,N,i):
            tmp ^= A[j]
        B[i] = tmp

    cnt = 0
    ans = []
    for i in range(1,N+1):
        if B[i] == 1:
            cnt += 1
            ans.append(i)

    print(cnt)
    print(*ans)

main()

Submission status: Wrong Answer

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

    B = [0] * (N+1)

    for i in range(N-1,0,-1):
        tmp = 0
        for j in range(i,N,i):
            tmp ^= A[j]
        B[i] = tmp

    cnt = 0
    ans = []
    for i in range(1,N+1):
        if B[i] == 1:
            cnt += 1
            ans.append(i)

    print(cnt)
    print(*ans)

main()

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
res = [0 for i in range(n)]
for i in range(n,n//2,-1):
    res[i-1] = a[i-1]

for i in range(n//2,0,-1):
    l = []
    flag = 0
    t = i*2
    while t <= n:
        flag = flag ^ res[t-1]
        t = t+i
    if a[i-1] != flag:
        res[i-1] = 1

if res == [0 for i in range(n)]:
    print(0)
else:
    lres = []
    for i in range(n):
        if res[i] == 1:
            lres.append(str(i+1))
    print(" ".join(lres))

Submission status: Wrong Answer

Solution code:
n,*a=map(int,open(0).read().split())
b=[0]*(n+1)
ans=[]
for i in range(n,0,-1):
    if sum (b[i::i])!=a[i-1]:
        b[i]=(b[i]+1)%2
        ans.append(i)
print(sum(b))
print(*ans[::-1])

Submission status: Wrong Answer

Solution code:
n,*a=map(int,open(0).read().split())
b=[0]*(n+1)
ans=[]
for i in range(n,0,-1):
    if sum (b[i::i])!=a[i-1]:
        b[i]=(b[i]+1)%2
        ans.append(1)
print(sum(b))
print(*ans)

Submission status: Wrong Answer

Solution code:
N = int(raw_input())
A = list(map(int,raw_input().split()))
ans = [0]*N
for i in reversed(range(0, N)):
  ball = 0
  for j in range(i,N,i+1):
    ball = ball + ans[j]
  if (ball+A[i])%2!=0 :
    ans[i] = 1
print ans

Submission status: Wrong Answer

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

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

for i in reversed(range(N)):
    j = i + 1
    tmp = 0
    while j <= N:
        tmp += b[j - 1]
        j += j
    if (tmp + a[i]) % 2 == 1:
        b[i] = 1

M = sum(b)
print(M)
if M != 0:
    for i in range(N):
        if b[i] == 1:
            print(i + 1, end=' ')
    print('\n')

Submission status: Wrong Answer

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

M = 0
b = [0 for x in range(N)]

for i in reversed(range(N)):
    j = i + 1
    tmp = 0
    while j <= N:
        tmp += b[j - 1]
        j += j
    if (tmp + a[i]) % 2 == 1:
        b[i] = 1

M = sum(b)
print(M)
for i in range(N):
    if b[i] == 1:
        print(i + 1, end=' ')
print('\n')

Submission status: Wrong Answer

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

M = 0
b = [0 for x in range(N)]

for i in reversed(range(N)):
    if a[i]  == 1:
        j = i + 1
        tmp = 0
        while j <= N:
            tmp += b[j - 1]
            j += j
        if (tmp + a[i]) % 2 == 1:
            b[i] = 1

M = sum(b)
print(M)
for i in range(N):
    if b[i] == 1:
        print(i + 1, end=' ')
print('\n')

Submission status: Wrong Answer

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

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

# N = 6
# a =  [0, 0, 0, 1, 0, 1]
# ans: [1,    3, 4,    6]

# N = 6
# a =  [1, 1, 0, 1, 0, 1]
# ans: [1, 2, 3, 4,    6]

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


for i in range(N - 1, 0 , -1):
    # i は 5 から 1 までイテレートする
    # print('i', i)
    # print('a', a[::i][1:])
    # print('b', b[i::i+1])
    # print("")
    if (sum(a[::i][1:]) + sum(b[i::i+1])) % 2 == 0:
        b[i] = 0
    else:
        b[i] = 1

if a[0] == 0:
    b[0] = (sum(b[1:])) % 2
else:
    # print('kotti', sum(b[1:]))
    b[0] = (sum(b[1:]) + 1) % 2

# print('a', a)
# print('b', b)

s = sum(b)
print(s)
if s != 0:
    # print(*b[:last_index(b, 1) + 1])
    print(*[x + 1 for x in range(N) if 0 < b[x]])

Submission status: Wrong Answer

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

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

# N = 6
# a =  [0, 0, 0, 1, 0, 1]
# ans: [1,    3, 4,    6]

# N = 6
# a =  [1, 1, 0, 1, 0, 1]
# ans: [1, 2, 3, 4,    6]

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


for i in range(N - 1, 0 , -1):
    # i は 5 から 1 までイテレートする
    print('i', i)
    print('a', a[::i][1:])
    print('b', b[i::i+1])
    print("")
    if (sum(a[::i][1:]) + sum(b[i::i+1])) % 2 == 0:
        b[i] = 0
    else:
        b[i] = 1

if a[0] == 0:
    b[0] = (sum(b[1:])) % 2
else:
    print('kotti', sum(b[1:]))
    b[0] = (sum(b[1:]) + 1) % 2

print('a', a)
print('b', b)

s = sum(b)
print(s)
if s != 0:
    # print(*b[:last_index(b, 1) + 1])
    print(*[x + 1 for x in range(N) if 0 < b[x]])

Submission status: Wrong Answer

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

N = int(input())
a = list(map(int, input().split()))
b = [0 for _ in range(N)]


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

b[0] = (sum(a) + sum(b[1:])) % 2

s = sum(b)
print(s)
if s != 0:
    print(*[x + 1 for x in range(N) if 0 < b[x]])

Submission status: Wrong Answer

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

        print(i+1)
        break
[print(x) for x in b]

Submission status: Wrong Answer

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

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

# a = [1, 0, 0]
# N = 3

# a = [0, 0, 0, 0, 0]
# N = 5

# a = [1, 1]
# N = 2

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

# def last_index(lst, val):
#     return len(lst) - 1 - lst[::-1].index(val)


for i in range(N - 1, 0, -1):
    # if sum(a[::i][1:]) % 2 == 0:
    if (sum(a[::i][1:]) + sum(b[i::i][1:])) % 2 == 0:
        b[i] = 0
    else:
        b[i] = 1

b[0] = (sum(a) + sum(b[1:])) % 2

s = sum(b)
print(s)
if s != 0:
    # print(*b[:last_index(b, 1) + 1])
    print(*[x + 1 for x in range(N) if 0 < b[x]])

Submission status: Wrong Answer

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

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

# a = [1, 0, 0]
# N = 3

# a = [0, 0, 0, 0, 0]
# N = 5

# a = [1, 1]
# N = 2

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

# def last_index(lst, val):
#     return len(lst) - 1 - lst[::-1].index(val)


for i in range(N - 1, 0, -1):
    b[i] = sum(a[::i][1:]) % 2

b[0] = sum(a) % 2

s = sum(b)
print(s)
if s != 0:
    # print(*b[:last_index(b, 1) + 1])
    print(*[x + 1 for x in range(N) if 0 < b[x]])

Submission status: Wrong Answer

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

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

# a = [1, 0, 0]
# N = 3

# a = [0, 0, 0, 0, 0]
# N = 5

# a = [1, 1]
# N = 2

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

def last_index(lst, val):
    return len(lst) - 1 - lst[::-1].index(val)


for i in range(N - 1, 0, -1):
    b[i] = sum(a[::i][1:]) % 2

b[0] = sum(a) % 2

s = sum(b)
print(s)
if s != 0:
    print(*b[:last_index(b, 1) + 1])