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:
from collections import defaultdict, deque
import sys, heapq, bisect, math, itertools, string, queue, copy, time
from fractions import gcd
import numpy as np
sys.setrecursionlimit(10**8)
INF = float('inf')
MOD = 10**9+7
EPS = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())




N = int(input())
alist = list(map(int, input().split()))
ans_list = []
for i in range(len(alist)):
    bef = 0
    for j in range(2, len(alist)):
        if (N-i)*j > N:
            break
        else:
            bef += alist[(N-i)*j-1]
    if alist[N-i-1] != bef%2:
        ans_list.append(N-i)
print(len(ans_list))
print(*ans_list)

Submission status: Wrong Answer

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

B = [0]*(n+1)
for i in range(n, 0, -1):
    B[i] = sum(A[::i]) % 2

print(sum(B))
print(*(i for i, b in enumerate(B) if b))

Submission status: Wrong Answer

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

ans_m = 0
ans_b = []
for i in range(n-1,n//2-1,-1):
    # print(i)
    if a[i] == 1:
        b[i] = 1
        ans_m += 1
        ans_b.append(i+1)
        
        # print(i+1)

# print(b)
for i in range(n//2-1,-1,-1):
    # print(i)
    s = 0
    for j in range(i+2,n+1,i+1):
        # print(j)
        s += b[j-1]
        # print([i+1,j])
    # print(s)
    if s % 2 != a[i]:
        b[i] = 1
        ans_m += 1
        ans_b.append(i+1)
        # print(i+1)

# print(b)

print(ans_m)
print(*ans_b)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32

MOD = 2  # type: int

def solve(N: int, a: "List[int]"):
    a = [0] + a
    b = [0] * (N+1)
    for i in range(N,0,-1):
        j = i*2
        n = 0
        while j <= N:
            n += a[j]
            j += i
        # print("a[i],n :", i, a[i], n)
        if a[i] == n%MOD:
            b[i] = 0
        else:
            b[i] = 1

    x = [i for i in range(1, N+1) if b[i] == 1]
    print(len(x))
    for i in x:
        print(i)

    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, a)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32

MOD = 2  # type: int

def solve(N: int, a: "List[int]"):
    a = [0] + a
    b = [0] * (N+1)
    for i in range(N,0,-1):
        j = i
        n = 0
        while j < N:
            n += a[i]
            j *= 2
        if a[i] == n%MOD:
            b[i] = 0
        else:
            b[i] = 1

    x = [i for i in range(1, N+1) if b[i] == 1]
    print(len(x))
    for i in x:
        print(i)

    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, a)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32

MOD = 2  # type: int

def solve(N: int, a: "List[int]"):
    a = [0] + a
    b = [0] * (N+1)
    for i in range(N,0,-1):
        j = i
        n = 0
        while j < N:
            n += a[i]
            j *= 2
        if a[i] == n:
            b[i] = 0
        else:
            b[i] = 1

    x = [i for i in range(1, N+1) if b[i] == 1]
    print(len(x))
    for i in x:
        print(i)

    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, a)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

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

ans_list = [0] * N
ans_text = ''
for i in range(N):
  # j の倍数が何個あるか
  j = N - i
  sum_j = sum(ans_list[j-1::j])
  if sum_j != a_list[j-1]:
    ans_list[j-1] = 1
    ans_text += str(j) + ' '
    
print(sum(ans_list))
print(ans_text)

Submission status: Wrong Answer

Solution code:
# 初期状態で半分から向こうは自分自身の値ということで確定
# 後ろからみていく 間に合いそうにないけど間に合う
# いい入れ方は必ず存在する？
# え なんでこれがWAなのかまるでわからん 正解では？？？？？？？

n = int(input())
arr = list(map(int, input().split()))
lis = [0 for _ in range(n)]

for i in range(n, 0, -1):
    # print("i : {}".format(i))
    count = 0
    for j in range(i - 1, n, i):
        # print(j, end=" ")
        if arr[j] == 1:
            count += 1
    lis[i - 1] = count % 2
    # print("i={}時点での結果 count = {} lis = {}".format(i, count, lis))

if lis == arr:
    ans = []
    for i, l in enumerate(lis):
        if l > 0:
            ans.append(i + 1)
    print(len(ans))
    print(" ".join(list(map(str, ans))))
else:
    print(0)

Submission status: Wrong Answer

Solution code:
# 初期状態で半分から向こうは自分自身の値ということで確定
# 後ろからみていく 間に合いそうにないけど間に合う
# いい入れ方は必ず存在する？

n = int(input())
arr = list(map(int, input().split()))
lis = [0 for _ in range(n)]

for i in range(n, 0, -1):
    # print("i : {}".format(i))
    count = 0
    for j in range(i - 1, n, i):
        # print(j, end=" ")
        if arr[j] == 1:
            count += 1
    lis[i - 1] = count % 2
    # print("i={}時点での結果 count = {} lis = {}".format(i, count, lis))
ans = []
for i, l in enumerate(lis):
    if l > 0:
        ans.append(i + 1)
print(len(ans))
print(" ".join(list(map(str, ans))))

Submission status: Wrong Answer

Solution code:
# 初期状態で半分から向こうは自分自身の値ということで確定
# 後ろからみていく 間に合いそうにないけど間に合う
# いい入れ方は必ず存在する？

n = int(input())
arr = list(map(int, input().split()))
ans = [0 for _ in range(n)]

for i in range(n, 0, -1):
    # print("i : {}".format(i))
    count = 0
    for j in range(i - 1, n, i):
        # print(j, end=" ")
        if arr[j] == 1:
            count += 1
    ans[i - 1] = count % 2
    # print("i={}時点での結果 {}".format(i, ans))
# print("ans = {}".format(ans))
print(sum(ans))
for i in range(n):
    if ans[i] == 1:
        print(i + 1)

Submission status: Wrong Answer

Solution code:
# 初期状態で半分から向こうは自分自身の値ということで確定
# 後ろからみていく 間に合いそうにないけど間に合う
# いい入れ方は必ず存在する？

n = int(input())
arr = list(map(int, input().split()))
ans = [0 for _ in range(n)]

for i in range(n, 0, -1):
    # print("i : {}".format(i))
    count = 0
    for j in range(i - 1, n, i):
        # print(j, end=" ")
        if arr[j] == 1:
            count += 1
    ans[i - 1] = count % 2
    # print("i={}時点での結果 {}".format(i, ans))
print("ans = {}".format(ans))
print(sum(ans))
for i in range(n):
    if ans[i] == 1:
        print(i + 1)

Submission status: Wrong Answer

Solution code:
# 初期状態で半分から向こうは自分自身の値ということで確定
# 後ろからみていく 間に合いそうにないけど間に合う
# いい入れ方は必ず存在する？
# なんか実装しにくい（阿呆だからだね

n = int(input())
arr = list(map(int, input().split()))
ans = [0 for _ in range(n)]

for i in range(n, 0, -1):
    # print("i : {}".format(i))
    count = 0
    for j in range(i - 1, n, i):
        # print(j, end=" ")
        if arr[j] == 1:
            count += 1
    if count % 2 == 1:
        ans[i - 1] = 1
    # print("i={}時点での結果 {}".format(i, ans))
print(sum(ans))
for i in range(n):
    if ans[i] == 1:
        print(i + 1)

Submission status: Wrong Answer

Solution code:
# 後ろから判定してエラトステネスっぽく更新していく

n = int(input())
arr = list(map(int, input().split()))
boxes = [0 for _ in range(n)]

for i in range(n, 0, -1):
    # print("i = {}".format(i))
    tmp = arr[i - 1]
    for j in range(i + i - 1, n, i):
        # print("   j = {}".format(j))
        tmp += arr[j]
        tmp %= 2
    # print("tmp = {}".format(tmp))
    if boxes[i - 1] != tmp:
        # print("ということで変更")
        arr[i - 1] += 1
        arr[i - 1] %= 2
        boxes[i - 1] += 1

# print(boxes)
ans = list(filter(lambda v: v[1] > 0, enumerate(boxes)))
print(len(ans))
if len(ans) > 0:
    ans = list(map(lambda x: str(x[0] + 1), ans))
    print(" ".join(ans))

Submission status: Wrong Answer

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

b = [0] * (N + 1)
ans = []
for i in range(1,N+1)[::-1]:
    t = N // i 
    s = sum(b[i+i::i])
    if a[i] != s:
        b[i] = 1
        ans.append(i)

if ans == []:
    print(0)
else:
    print(len(ans))
    print(" ".join(map(str, ans)))

Submission status: Wrong Answer

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

b = []
for i in range(1,N+1)[::-1]:
    s = sum(a[i+i::i])
    if a[i] != s:
        b.append(i)

if b == []:
    print(0)
else:
    print(len(b))
    print(" ".join(map(str, b)))

Submission status: Wrong Answer

Solution code:

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

for i in list(range(1, N+1))[::-1]:
  tmp = i
  cnt = 0
  while tmp < N:
    if tmp in B:
      cnt += 1    
    tmp += i

  if cnt % 2 != A[i-1]:
    B.add(i)

len_b = len(B)
if len_b == 0:
  print(0)
else:
  print(len_b)
  print(*sorted(list(B)))

Submission status: Wrong Answer

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

for i in range(n):
  c = 0
  for j in b:
    if j%(n-i)|1:
      c+=1
  if a[n-1-i] | c%2:
    b.append(n-i)
print(len(b))
if len(b)>0:
  print(*b)

Submission status: Wrong Answer

Solution code:
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time


def I(): return int(input())


def MI(): return map(int, input().split())


def S(): return input()


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YN = ['No', 'Yes']
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']


show_flg = True
show_flg = False


def main():
    N = I()
    a = LI()
    b = [0] * N

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

        for cur in range(i, N, i+1):
            total += b[cur-1]

        if a[i-1] != total % 2:
            b[i-1] = 1
        # print(*b)

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

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


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time


def I(): return int(input())


def MI(): return map(int, input().split())


def S(): return input()


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YN = ['No', 'Yes']
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']


show_flg = True
show_flg = False


def main():
    N = I()
    a = LI()
    b = [0] * N

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

        for cur in range(i, N, i+1):
            total += b[cur-1]

        if a[i-1] != total % 2:
            b[i-1] = 1
        # print(*b)

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

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


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
import fractions
from functools import reduce

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
    
def pin(type=int):
    return map(type,input().split())


N, =pin()
A = list(pin())#a1=A[0]
"""
#考察
i の倍数が書かれた箱に入っているボールの個数の和を 2 で割った「余り」が ai である。
ここで、Aの中身が全部0ならあまりが偶数なのだが実際の数も0を含む
そのため、”よい入れ方”を作るときには0のみとなるのが容易な答えとなる

逆に、Aの中身に1が混じっていることでその入れ方（何も入れない）ができなくなる
"""
"""
考察2
i=1 すべての箱に入っている個数の和を2で割ったあまり<=>int(M) % 2
I={A[I]=1|Iは自然数}と集合をていぎしたら…
a1=0なら2個、a1=1なら1個の玉をIの部分集合とその補集合についてのLCM（ただし。うまく互いに素になるように）を求めれば済ませられるのでは。
-1をつけなくて良い
"""
odd=[]
for i in range(1,N):
    if A[i]==1:
        odd.append(i+1)


#print(odd)
if (A[0] == 1):
    #A[1]=1とどうち LCM出力
    print(1)
    print(lcm_list(odd))
elif len(odd)==0:
    print(0)
else:
    print(2)
    print(lcm_list(odd),200003)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
import fractions
from functools import reduce

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
    
def pin(type=int):
    return map(type,input().split())


N, =pin()
A = list(pin())#a1=A[0]
"""
#考察
i の倍数が書かれた箱に入っているボールの個数の和を 2 で割った「余り」が ai である。
ここで、Aの中身が全部0ならあまりが偶数なのだが実際の数も0を含む
そのため、”よい入れ方”を作るときには0のみとなるのが容易な答えとなる

逆に、Aの中身に1が混じっていることでその入れ方（何も入れない）ができなくなる
"""
"""
考察2
i=1 すべての箱に入っている個数の和を2で割ったあまり<=>int(M) % 2
I={A[I]=1|Iは自然数}と集合をていぎしたら…
a1=0なら2個、a1=1なら1個の玉をIの部分集合とその補集合についてのLCM（ただし。うまく互いに素になるように）を求めれば済ませられるのでは。
-1をつけなくて良い
"""
odd=[]
for i in range(1,N):
    if A[i]==1:
        odd.append(i+1)


#print(odd)
if (A[0] == 1):
    #A[1]=1とどうち LCM出力
    print(1)
    print(lcm_list(odd))
elif len(odd)==0:
    print(0)
    print(0)
else:
    print(2)
    print(lcm_list(odd),200003)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
import fractions
from functools import reduce

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
    
def pin(type=int):
    return map(type,input().split())


N, =pin()
A = list(pin())#a1=A[0]
"""
#考察
i の倍数が書かれた箱に入っているボールの個数の和を 2 で割った「余り」が ai である。
ここで、Aの中身が全部0ならあまりが偶数なのだが実際の数も0を含む
そのため、”よい入れ方”を作るときには0のみとなるのが容易な答えとなる

逆に、Aの中身に1が混じっていることでその入れ方（何も入れない）ができなくなる
"""
"""
考察2
i=1 すべての箱に入っている個数の和を2で割ったあまり<=>int(M) % 2
I={A[I]=1|Iは自然数}と集合をていぎしたら…
a1=0なら2個、a1=1なら1個の玉をIの部分集合とその補集合についてのLCM（ただし。うまく互いに素になるように）を求めれば済ませられるのでは。
-1をつけなくて良い
"""
odd=[]
for i in range(1,N):
    if A[i]==1:
        odd.append(i+1)


#print(odd)
if (A[0] == 1):
    #A[1]=1とどうち LCM出力
    print(1)
    print(lcm_list(odd))
elif len(odd)==0:
    print(0)
    print(0)
else:
    print(2)
    print(lcm_list(odd),200002)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
ans_l = [0]*n
print(ans_l)
for i in reversed(range(1,n)):
    print(i)
    print(sum(ans_l[(i)::(i+1)]))
    if sum(ans_l[(i)::(i+1)])%2 != a[i]:
        ans_l[i] += 1
if sum(ans_l)%2 != a[0]:
    ans_l[0] += 1
ans = []
for i in range(n):
    if ans_l[i]==1:
        ans.append(i+1)
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()))
ans_l = [0]*n
for i in reversed(range(1,n)):
    if sum(ans_l[(i-i)::i])%2 != a[i]:
        ans_l[i] += 1
if sum(ans_l) != a[0]:
    ans_l[0] += 1
ans = []
for i in range(n):
    if ans_l[i]==1:
        ans.append(i+1)
print(len(ans))
if len(ans)>0:
    print(" ".join(map(str, ans)))

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
import fractions
from functools import reduce
def pin(type=int):
    return map(type,input().split())


N, =pin()
m = list(pin())




def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

print(gcd_list(m))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
import sys
minint = -sys.maxsize - 1
maxint = sys.maxsize

n = int(input())
a = str(input()).split()
print(0)

Submission status: Wrong Answer

Solution code:
n = input()
a = input().split()
print(n, a)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
LOCAL = len(sys.argv) > 1 and sys.argv[1] == 'LOCAL'


def dprint(*args):
  if LOCAL:
    print(*args)


n = int(input())
a = [None] + list(map(int, input().split()))

b = [0] * (n + 1)
for i in range(n, 0, -1):
  dprint('i', '=', i)
  t = 0
  for j in range(i, n + 1, i):
    dprint('j', '=', j)
    t += a[i]
  b[i] = t % 2

dprint(b)

print(b.count(1))
for i, x in enumerate(b):
  if x == 1:
    print(i)

Submission status: Wrong Answer

Solution code:
n=int(input())
A=list(map(int,input().split()))
ans=[]
cnt=0
for i in range(n-1,-1,-1):
    a=i+1
    c=0
    while a<=n:
        if A[a-1]==1:
            c+=1
        a+=i+1
    if c%2==1:
        ans.append(i+1)
        cnt+=1
if cnt==0:
    print(0)
else:
    print(cnt)
    ans.sort()
    print(*ans, sep=' ')

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int, input().split()))
aN = 0
al = [0] * N
ans = []
for i in reversed(range(N)):
    total = 0
    for j in range(2 * (i + 1) - 1, N, i + 1):
        total ^= al[j]
    al[i] = total ^ a[i]

for i in  al:
    if i:
        ans.append(i)
print(len(ans))
for i in ans:
    print(i, end=' ')

Submission status: Wrong Answer

Solution code:
import numpy as np
N = int(input())
a = list(map(int, input().split()))
aN = 0
al = [0] * N
na = np.array(al)
ans = []
for i in reversed(range(N)):
    tmp = na[i: i + 1: N].sum()
    if tmp % 2 != a[i]:
        ans.append(1)
        na[i] = 1

print(len(ans))
for i in ans:
    print(i, end='')

Submission status: Wrong Answer

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

ans = []

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

  tmp = j
  while tmp <= N:
    cnt += A[N - tmp]
    tmp += j
  
  if cnt % 2 == 1:
    ans.append(j)

len_ans = len(ans)
if len_ans == 0:
  print(0)
else:
  print(len_ans)
  print(*ans[::-1])

Submission status: Wrong Answer

Solution code:
import numpy as np
N = int(input())
a = list(map(int, input().split()))
aN = 0
al = [0] * N
na = np.array(al)
for i in reversed(range(N)):
    tmp = na[i: i + 1: N].sum()
    if tmp % 2 != a[i]:
        aN += 1
        na[i] = 1

print(aN)
print(*na)

Submission status: Wrong Answer

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

ans = []

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

  tmp = j
  while tmp < N:
    cnt += A[N - tmp]
    tmp += j
  
  if cnt % 2 == 1:
    ans.append(j)

len_ans = len(ans)
if len_ans == 0:
  print(0)
else:
  print(len_ans)
  print(*ans[::-1])

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
B = [0 for _ in range(N)]
for i in range(N, 0, -1):
  S = sum(B[m*i-1] for m in range(1, N//i))
  B[i-1] = (A[i-1] + S) % 2
C = []
for i in range(N):
  if B[i] == 1:
    C.append(i+1)
print(len(C))
for i in range(len(C)):
  if i != len(C) - 1:
    print(C[i], end = ' ')
  else:
    print(C[i])

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
B = [0 for _ in range(N)]
B = B[:N//2] + A[N//2:]
for i in range(2, N+1):
  for j in range(N//(i+1), N//i):
    S = sum(B[m] for m in range(2*j+1, N, i))
    B[j] = (S + A[j]) % 2
C = []
for i in range(N):
  if B[i] == 1:
    C.append(i+1)
print(len(C))
for i in range(len(C)):
  if i != len(C) - 1:
    print(C[i], end = ' ')
  else:
    print(C[i])

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
B = [0 for _ in range(N)]
for i in range(1, N+1):
  for j in range(N//(i+1), N//i):
    S = sum(B[m] for m in range(2*j+1, N, i))
    B[j] = (S + A[j]) % 2
C = []
for i in range(N):
  if B[i] == 1:
    C.append(i+1)
print(len(C))
for i in range(len(C)):
  if i != len(C) - 1:
    print(C[i], end = ' ')
  else:
    print(C[i])

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
B = [0 for _ in range(N)]
for i in range(1, N+1):
  for j in range(N//(i+1), N//i):
    S = sum(B[i] for i in range(2*j+1, N, i))
    B[j] = (S + A[j]) % 2
C = []
for i in range(N):
  if B[i] == 1:
    C.append(i+1)
print(len(C))
for i in range(len(C)):
  if i != len(C) - 1:
    print(C[i], end = ' ')
  else:
    print(C[i])

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
balls = [0 for _ in range(N)]
ans = []
for i in range(N-1, -1, -1):
    if N - 1 < 2 * i:
        if A[i] == 1:
            balls[i] = 1
    elif i == 0:
        sum_balls = sum(balls)
        if (sum_balls % 2 == 1 and A[i] == 0) or (sum_balls % 2 == 0 and A[i] == 1):
            balls[i] = 1
            ans.append(i + 1)
    else:
        if (A[2*i] == 1 and A[i] == 0) or (A[2*i] == 0 and A[i] == 1):
            balls[i] = 1
            ans.append(i + 1)
print(sum(balls))
print(*ans)

Submission status: Wrong Answer

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

ans = []

i = -1
while -i < n+1:
    j = n - i
    times = j
    cnt = 0

    if j == 1:
        cnt = sum(a)
    else:
        while j < n:
            cnt += b[j]
            j *= times

    if cnt % 2 != a[i]:
        b[i] = 1
        ans.append(n+i+1)

    else:
        b[i] = 0

    i -= 1

print(len(ans))
print(*ans[::-1])

Submission status: Wrong Answer

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

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

box = [0]*(N+1)

for i in range(N,0,-1):
    k=2
    ball=a[i-1]
    #print(123,i,ball)
    while i*k<=N:
        if a[i*k-1]==1:
            ball = (ball+1)%2
        k+=1
    box[i] = ball
#print(box)
M=0
b=[]
for i in range(1,N+1):
    if box[i]==1:
        M+=1
        b.append(i)

print(M)
[print(x) for x in b]

Submission status: Wrong Answer

Solution code:
N=int(input())
a = list(map(int,input().split()))
if N == 1:
    print(a[0])
    if a[0] == 1:
        print(1)
else:
    ball = [0 for i in range(N)]
    ans = []
    for i in range(N-1,-1,-1):
        sumi = sum(ball[2*i+1::i+1])
        if a[i] != sumi%2:
            ans.append(i+1)
    ans.sort()
    print(len(ans))
    if len(ans) != 0:
        print(*ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N=int(input())
a = list(map(int,input().split()))
if N == 1:
    print(a[0])
    if a[0] == 1:
        print(1)
else:
    ans = []
    for i in range(N-1,-1,-1):
        sumi = sum(a[i+j*(i+1)] for j in range(1,N//(i+1)))
        if a[i] != sumi%2:
            ans.append(i+1)
    ans.sort()
    print(len(ans))
    if len(ans) != 0:
        print(*ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
a = list(map(int,input().split()))
if N == 1:
    print(a[0])
    if a[0] == 1:
        print(1)
else:
    ans = []
    for i in range(N-1,-1,-1):
        sumi = sum(a[i+j*(i+1)] for j in range(1,N//(i+1)))
        if a[i] != sumi%2:
            ans.append(i+1)
    ans.reverse()
    print(len(ans))
    if len(ans) != 0:
        print(*ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
a = list(map(int,input().split()))
if N == 1:
    print(a[0])
    if a[0] == 1:
        print(1)
else:
    latter = [i+1 for i in range(N//2,N) if a[i] == 1]
    former = []
    for i in range(N//2-1,0,-1):
        sumi = sum(a[i+j*(i+1)] for j in range(1,N//(i+1)+1) if i+j*(i+1) <= N-1)
        if a[i] != sumi%2:
            former.append(i+1)
    if (len(former)+len(latter))%2 != a[0]:
        former.append(1)
    former.reverse()
    ans = former + latter
    print(len(ans))
    print(*ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
a = list(map(int,input().split()))
if N == 1:
    print(a[0])
    if a[0] == 1:
        print(1)
else:
    latter = [i+1 for i in range(N//2,N) if a[i] == 1]
    former = []
    for i in range(N//2,0,-1):
        sumi = sum(a[i+j*(i+1)] for j in range(1,N//(i+1)+1) if i+j*(i+1) <= N-1)
        if a[i] != sumi%2:
            former.append(i+1)
    if (len(former)+len(latter))%2 != a[0]:
        former.append(1)
    former.reverse()
    ans = former + latter
    print(len(ans))
    print(*ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
a = list(map(int,input().split()))
if N == 1:
    print(a[0])
    if a[0] == 1:
        print(1)
else:
    latter = [i+1 for i in range(N//2,N) if a[i] == 1]
    former = []
    for i in range(1,N//2):
        sumi = sum(a[i+j*(i+1)] for j in range(1,N//(i+1)+1) if i+j*(i+1) <= N-1)
        if a[i] != sumi%2:
            former.append(i+1)
    if (len(former)+len(latter))%2 != a[0]:
        former.append(1)
    former.reverse()
    ans = former + latter
    print(len(ans))
    print(*ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
a = list(map(int,input().split()))
if N == 1:
    print(a[0])
    if a[0] == 1:
        print(1)
else:
    latter = [i+1 for i in range(N//2,N) if a[i] == 1]
    former = []
    for i in range(1,N//2):
        sumi = sum(a[i+j*(i+1)] for j in range(1,N//i+1) if i+j*(i+1) <= N-1)
        if a[i]-sumi%2 == 1:
            former.append(i+1)
    if (len(former)+len(latter))%2 != a[0]:
        former.append(1)
    former.reverse()
    ans = former + latter
    print(len(ans))
    print(*ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
a = list(map(int,input().split()))
if N == 1:
    print(a[0])
    if a[0] == 1:
        print(1)
else:
    latter = [i+1 for i in range(N//2,N) if a[i] == 1]
    former = []
    for i in range(1,N//2):
        sumi = sum(a[i+j*(i+1)] for j in range(1,N//i+1) if i+j*(i+1) <= N-1)
        if a[i]-sumi%2 == 1:
            former.append(i+1)
    if sum(former)%2 != a[0]:
        former.append(1)
    former.reverse()
    ans = former + latter
    print(len(ans))
    print(*ans)

Submission status: Wrong Answer

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

r = [None] * N
# A = A[::-1]  # 扱いやすくするためにひっくり返す

# nの倍数の箱に入っているボールの個数
# (nは含まない)
def f(n):
    i = 2
    cnt = 0
    while n * i <= N:
        # print('-', n, i, r)
        cnt += r[(n * i)-1]
        i += 1
    # print('--', n, cnt, r)
    return cnt

n = N
while n > 0:
    c = f(n)
    # print(n, c, A[n-1])
    if c % 2 == A[n-1]:
        r[n-1] = 0
    else:
        r[n-1] = 1
    n -= 1

# print(r)

r_a = []
if r.count(0) == N:
    print(0)
else:
    for i, ri in enumerate(r):
        if ri == 1:
            r_a.append(str(i+1))

    print(" ".join(r_a))

Submission status: Wrong Answer

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

r = [None] * N
# A = A[::-1]  # 扱いやすくするためにひっくり返す

# nの倍数の箱に入っているボールの個数
# (nは含まない)
def f(n):
    i = 2
    cnt = 0
    while n * i <= N:
        # print('-', n, i, r)
        cnt += r[(n * i)-1]
        i += 1
    # print('--', n, cnt, r)
    return cnt

n = N
while n > 0:
    c = f(n)
    # print(n, c, A[n-1])
    if c % 2 == A[n-1]:
        r[n-1] = 0
    else:
        r[n-1] = 1
    n -= 1

# print(r)

if r.count(0) == N:
    print(0)
else:
    for i, ri in enumerate(r):
        if ri == 1:
            print(i+1, end=" ")

Submission status: Wrong Answer

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