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: Time Limit Exceeded

Solution code:
import sys

import numpy as np

readline = sys.stdin.buffer.readline


def main():
    N = int(readline())
    A = [0] + list(map(int, readline().split()))
    A = np.array(A)
    C = np.zeros(N + 1, dtype=np.int32)

    if A[-1] == 1:
        C[-1] == 1

    for j in range(N, 0, -1):
        cnt = np.count_nonzero(C[j::j] == 1)

        if cnt % 2 == 0:
            if A[j] == 0:
                C[j] = 0
            else:
                C[j] = 1
        else:
            if A[j] == 0:
                C[j] = 1
            else:
                C[j] = 0

    ans = np.sum(C)
    print(ans)
    if ans != 0:
        for i, c in enumerate(C):
            if c == 1:
                print(i)


main()

Submission status: Time Limit Exceeded

Solution code:
import sys

import numpy as np

readline = sys.stdin.buffer.readline


def main():
    N = int(readline())
    A = [0] + list(map(int, readline().split()))
    A = np.array(A)
    C = np.zeros(N + 1, dtype=np.int32)

    if A[-1] == 1:
        C[-1] == 1

    for j in range(N, 0, -1):
        cnt = np.sum(C[j::j])

        if cnt % 2 == 0:
            if A[j] == 0:
                C[j] = 0
            else:
                C[j] = 1
        else:
            if A[j] == 0:
                C[j] = 1
            else:
                C[j] = 0

    ans = np.sum(C)
    print(ans)
    if ans != 0:
        for i, c in enumerate(C):
            if c == 1:
                print(i)


main()

Submission status: Time Limit Exceeded

Solution code:
import sys

import numpy as np

readline = sys.stdin.buffer.readline


def main():
    N = int(readline())
    A = [0] + list(map(int, readline().split()))
    A = np.array(A)
    C = np.zeros(N + 1, dtype=np.int32)

    for i in range(N):
        j = N - i
        cnt = np.sum(C[A % j == 0])

        if cnt % 2 == 0:
            if A[j] == 0:
                C[j] = 0
            else:
                C[j] = 1
        else:
            if A[i] == 0:
                C[j] = 1
            else:
                C[j] = 0

    ans = np.sum(C)
    print(ans)
    if ans != 0:
        for i, c in enumerate(C):
            if c == 1:
                print(i)


main()

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
N=int(input())
A=[int(i) for i in input().split()]
B=np.zeros(N)
for a in range(1,N+1)[::-1]:
    if N % a ==0:
        idx=np.arange(a,N+a,a)-1
    else:
        idx=np.arange(a,N,a)-1
    B[a-1] = (A[a-1] - B[idx].sum()) % 2
B=B 
ans=np.where(B!=0)[0]+1
print(len(ans))
if len(ans)!=0:
    print(*ans)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
N=int(input())
A=[int(i) for i in input().split()]
B=np.zeros(N)
for a in range(1,N+1)[::-1]:
    if N % a ==0:
        idx=np.arange(a,N+a,a)-1
    else:
        idx=np.arange(a,N,a)-1
    #print(a,A[a-1],idx,B[idx].sum())
    B[a-1] = (A[a-1] - B[idx].sum())
B=B.astype('int') % 2
ans=np.where(B!=0)[0]+1
print(len(ans))
if len(ans)!=0:
    print(*ans)

Submission status: Time Limit Exceeded

Solution code:
def divisors(n: int)->list:
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            yield i
            if i != n // i:
                yield n // i


def preparing_boxes(N: int, A: list)->list:
    B = []
    # C = [0] * N

    for i in range(N, 0, -1):
        # print('=== {} ==='.format(i))
        a = A[i-1]
        if a == 0:
            continue
        B.append(i)
        # C[i-1] = 1

        for div in divisors(i):
            # print(div)
            A[div-1] = 1 - A[div-1]

    # print(''.join(str(i) for i in C))

    return B


if __name__ == "__main__":
    N = int(input())
    A = list(map(int, input().split()))
    ans = preparing_boxes(N, A)
    print(len(ans))
    print(' '.join(str(i) for i in ans))

Submission status: Time Limit Exceeded

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


def preparing_boxes(N: int, A: list)->list:
    B = []
    # C = [0] * N

    for i in range(N, 0, -1):
        # print('=== {} ==='.format(i))
        a = A[i-1]
        if a == 0:
            continue
        B.append(i)
        # C[i-1] = 1

        for div in divisors(i):
            # print(div)
            A[div-1] = 1 - A[div-1]

    # print(''.join(str(i) for i in C))

    return B


if __name__ == "__main__":
    N = int(input())
    A = list(map(int, input().split()))
    ans = preparing_boxes(N, A)
    print(len(ans))
    print(' '.join(str(i) for i in ans))

Submission status: Time Limit Exceeded

Solution code:
import sys

if sys.platform =='ios':
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

N = INT()
A = MAP()

A_R = A[::-1]
#print(A_R)

box = [0] * N

for idx,a in enumerate(A_R):
	number = N-idx
	count = 0
	for ix,b in enumerate(box):
		if (N-ix)%number == 0:
			count+=b
	odd = 1 if count%2 else 0
	#print('watching: {}, # of balls: {}'.format(number, count))
	#print('a/odd: ', a, odd)
	if a == odd:
		#print('irenai')
		box[idx] = 0
	else:
		#print('ireru!!!!!!')
		box[idx] = 1

#print(box)

M = sum(box)
ans = []
for idx,b in enumerate(box):
	if b: ans.append(N-idx)

print(M)
print(' '.join(map(str, ans)))

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin

n = int(stdin.readline().rstrip())
li = list(map(int,stdin.readline().rstrip().split()))

point = 0
lin = []

for i in range(n,0,-1):
    score = 0
    for j in range(i+1,n+1):
        if j % i == 0:
            score += li[j-1]
    if li[i-1] != score%2:
        point += 1
        lin.append(i)

print(point)
for i in lin:
    print(i)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
a = list(map(int,input().split()))
ans = []
def divisor(n):
  ret = [0]
  for i in range(2,int(n**(1/2))+1):
    if n%i==0:
      ret.append(i-1)
      
      comp=n//i
      if i!=comp:
        ret.append(comp-1)
      
  return ret

for i in reversed(range(N)):
  if a[i]:
    ans.append(i+1)
    lis = divisor(i+1)
    for j in lis:
      a[j]^=1
      
l = len(ans)
if l>0:
  print(l)
  print(*ans)
else:
  print(l)

Submission status: Time Limit Exceeded

Solution code:
import sys

input = sys.stdin.readline

def main(): 
    N = int(input())
    A = [0] + list(map(int, input().split()))
    
    ans = [0] * (N+1)
    c = 0
    for i in range(N, 0, -1):
        t = 0
        for j in range(2*i, N+1):
            t += ans[j]
            
        if A[i] != (t%2): 
            ans[i] = 1
            c += 1
            
    print(c)
    print('1 '*c)

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
import sys

read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs = sys.stdin.buffer.readlines


# rstrip().decode('utf-8')
# INF=float("inf")
#MOD=10**9+7
# sys.setrecursionlimit(2147483647)
# import math
import numpy as np
# import operator
# import bisect
# from heapq import heapify,heappop,heappush
#from math import gcd
# from fractions import gcd
# from collections import deque
# from collections import defaultdict
# from collections import Counter
# from itertools import accumulate
# from itertools import groupby
# from itertools import permutations
# from itertools import combinations
# from scipy.sparse import csr_matrix
# from scipy.sparse.csgraph import floyd_warshall
# from scipy.sparse.csgraph import csgraph_from_dense
# from scipy.sparse.csgraph import dijkstra
# map(int,input().split())


def main():
	n=int(input())
	A=np.array(read().split(),np.int64)
	ans=np.zeros(n+1,np.int64)
	
	for i in range(n,0,-1):
		ans[i]=(np.sum(ans[::i])%2) ^ A[i-1]
	
	print(np.sum(ans))
	print(*(np.where(ans==1))[0])
	
	
if __name__ == '__main__':
	main()

Submission status: Time Limit Exceeded

Solution code:
import math

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

    # divisors.sort()
    return divisors

n = int(input())
a = list(map(int, input().split()))
ans = [0 for i in range(n)]
ball = []

for ii in range(n):
    #print(ans)
    i = n-ii
    if(a[i-1]!=ans[i-1]):
        d = make_divisors(i)
        ball.append(i)
        for k in d:
            ans[k-1] = 1-ans[k-1]
print(len(ball))
print(' '.join(map(str,ball)))

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

# 約数列挙
def make_divisors(value):
    divisors = []
    # int(n ** 0.5) は valueの平方根（小数点以下切り捨て）
    for i in range(1, int(value ** 0.5) + 1):
        if value % i == 0:
            divisors.append(i)              # 約数の下半分を追加
            if i != value // i:             # iが中央値なら下記を飛ばす
                divisors.append(value//i)   # 約数の上半分を追加
    # ソートする場合は下記コメントをはずす
    # divisors.sort()
    return divisors

N = int(input())
a = list(map(int, input().split()))
memo = np.zeros(N)
anser = []
for i in range(N - 1, -1, -1):
    if (a[i] == 1 and memo[i] % 2 == 0) or (a[i] == 0 and memo[i] % 2 == 1):
        anser.append(i + 1)
        # iの約数を抽出
        divisors = make_divisors(i + 1)
        for j in divisors:
            memo[j - 1] += 1

print(len(anser))
if len(anser) >=  1:
    print(" ".join(map(str, anser)))


"""
3
0 1 0

"""

Submission status: Time Limit Exceeded

Solution code:
# 約数列挙
def make_divisors(value):
    divisors = []
    # int(n ** 0.5) は valueの平方根（小数点以下切り捨て）
    for i in range(1, int(value ** 0.5) + 1):
        if value % i == 0:
            divisors.append(i)              # 約数の下半分を追加
            if i != value // i:             # iが中央値なら下記を飛ばす
                divisors.append(value//i)   # 約数の上半分を追加
    # ソートする場合は下記コメントをはずす
    # divisors.sort()
    return divisors

N = int(input())
a = list(map(int, input().split()))
memo = [0] * N
anser = []
for i in range(N - 1, -1, -1):
    if (a[i] == 1 and memo[i] == 0) or (a[i] == 0 and memo[i] == 1):
        anser.append(i + 1)
        # iの約数を抽出
        divisors = make_divisors(i + 1)
        for j in divisors:
            memo[j - 1] = (memo[j - 1] + 1) % 2

print(len(anser))
if len(anser) >=  1:
    print(" ".join(map(str, anser)))


"""
3
1 1 0

"""

Submission status: Time Limit Exceeded

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

#print(ai)
dai={}
dbi={}
for i in range(1, n+1):
    dai.setdefault(i, ai[i-1])
    dbi.setdefault(i, 0)

#print(dai)
#print(dbi)

anssum=0
ans=[]
for i in range(1, n+1)[::-1]:
    #print(i)
    tmp=0
    for j in range(2, n+1):
        check=i*j
        if check <= n:
            tmp = tmp + dbi[check]
    tmp = tmp%2
    #print(str(tmp) + ", " + str(dai[i]))
    if tmp != dai[i]:
        dbi[i]=1
        anssum=anssum+1
        ans.append(i)

#print(dbi)
print(anssum)
if anssum != 0:
    print(" ".join(map(str, reversed(ans))))

Submission status: Time Limit Exceeded

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
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
            make_divisors(i+1, tmp)
    elif a[i] == 1:
        if (tmp[i+1]%2) == 0:
            ball_box.append(i+1)
            ball_num += 1
            make_divisors(i+1, tmp)
        else:
            continue

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

Submission status: Time Limit Exceeded

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)
            if i != n // i:
                divisors.append(n//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: Time Limit Exceeded

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
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: Time Limit Exceeded

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(len(cnt))
    print(*cnt)
else:
    print(0)

Submission status: Time Limit Exceeded

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: Time Limit Exceeded

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
    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: Time Limit Exceeded

Solution code:
from collections import defaultdict
N = int(input())
arr = list(map(int, input().split()))
puts = []
dd = defaultdict(int)
 
def make_divisors(n):
    divisors = []
    # Nの最大の約数は√N
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    # divisors.sort()
    return divisors
 
for i in range(1,N+1)[::-1]:
    if N//2 < i and arr[i-1] == 1:
        puts.append(i)
        ds = make_divisors(i)
        for j in ds:
            dd[j] += 1
    else:
        # c = len([p for p in puts if p % i == 0])
        c = dd[i]
        if (c % 2 == 0 and arr[i-1] == 1) or (c % 2 == 1 and arr[i-1] == 0):
            puts.append(i)
            ds = make_divisors(i)
            for j in ds:
                dd[j] += 1
 
print(len(puts))
if len(puts):
    print(" ".join(map(str, sorted(puts, reverse=True))))

Submission status: Time Limit Exceeded

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

for i in range(1,N+1)[::-1]:
    if N//2 < i and arr[i-1] == 1:
        puts.append(i)
    else:
        c = len([p for p in puts if p % i == 0])
        if (c % 2 == 0 and arr[i-1] == 1) or (c % 2 == 1 and arr[i-1] == 0):
            puts.append(i)

print(len(puts))
if len(puts):
    print(" ".join(map(str, sorted(puts, reverse=True))))

Submission status: Time Limit Exceeded

Solution code:
#134d
import math

#input
#3
#1 0 0
#output
#1
#1

N = int(input()) #1≤N≤2×10^5

#Nの後半は入力と一致するので直接代入   
ans = list(map(int, input().split()))

#N 個の空の箱が横一列に並んでいます。 左から i  (1≤i≤N) 番目の箱には整数 iが書かれています。
#それぞれの箱に対してボールを 1個入れるか何も入れないかを選ぶことができます。
#ここで、以下の条件を満たすようなボールの入れ方を、いいボールの入れ方と定めます。

# 1以上 N 以下の任意の整数 i について、i の倍数が書かれた箱に入っているボールの個数の和を 2 で割った余りが aiである。

#いいボールの入れ方は存在するでしょうか。存在するならば 1つ求めてください。

if N%2==0:
    first = int(N/2)-1
else:
    first = int((N-1)/2)-1

#前半部分を処理
for i in range(first,-1,-1): # Max:10^5ループ
    #print(i,"→",i+1,":",ans[i])
    
    multiple_list = [j for j in range(1,N+1) if j%(i+1)==0]
    #print("倍数:",multiple_list)
    #content = [ans[j-1] for j in multiple_list]
    #print("中身:",content)
    total = sum([ans[j-1] for j in multiple_list])
    
    if ans[i]==1 and total%2==0:
        ans[i] = 0
    elif ans[i]==0 and total%2==1:
        ans[i] = 1
        
#print(' '.join(map(str,ans)))
print(sum(ans))
print(' '.join(map(str,[j+1 for j in range(0,N) if ans[j]==1])))

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
A = list(map(int, input().split()))
num = [i for i in range(n)]
B = [0]*(n)
C = []
ans = 0
for i in range(n):
  if sum(B[j-1] for j in list(filter(lambda x:x%(n-i) == 0, num))) != A[n-i-1]:
    B[n-i-1] = 1
    ans += 1
    C.append(n-i)
print(ans)
print(*C)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
import sys
def input():
    return sys.stdin.readline()[:-1]
n = int(input())
a = list(map(int,input().split()))
ans = np.array(a)
k = 2
for i in range(n, 0, -1):
    if n/k < i:
        for x in range(2, k):
            ans[i-1] += ans[x * i - 1]
        ans[i-1] = ans[i-1] % 2
    else:
        while n/k >= i:
            k += 1
        else:
            for x in range(2, k):
                ans[i-1] += ans[x * i - 1]
            ans[i-1] = ans[i-1] % 2
print(np.sum(ans))
for p in np.ndarray.flatten(np.argwhere(ans) + 1):
    print(p, end=' ')

Submission status: Time Limit Exceeded

Solution code:

import numpy as np
n = int(input())
a = list(map(int,input().split()))
ans = np.array(a)
k = 2
for i in reversed(range(1, n+1)):
    if n/k < i:
        for x in range(2, k):
            ans[i-1] += ans[x * i - 1]
        ans[i-1] = ans[i-1] % 2
    else:
        while n/k >= i:
            k += 1
        else:
            for x in range(2, k):
                ans[i-1] += ans[x * i - 1]
            ans[i-1] = ans[i-1] % 2
print(np.sum(ans))
for p in np.ndarray.flatten(np.argwhere(ans) + 1):
    print(p, end=' ')

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
N = int(input())
a = [int(i) for i in input().split()]
zeros = np.zeros(N)
index = np.arange(1, N + 1)
middle = int(N / 2) + 1
 
for i, e in zip(a[::-1], index[::-1]):
    if e >= middle:
        zeros[e - 1] = i
    else:
        if sum(zeros[index % e == 0]) % 2 == i:
            pass
        else:
            zeros[e - 1] = 1
 
M = sum(zeros)
print(int(M))
 
for i, e in zip(zeros, index):
    if i == 1:
        print(e, end=" ")

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
a= list(map(int, input().split()))
li=[]
for i in range(n-1,-1,-1):
    check=0
    for j in range(n//(i+1)):
        check+=(i+1)*(j+1) in li
    if check%2!=a[i]:
        li.append(i+1)
print(len(li))
print(" ".join(map(str,li)))

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = list(map(int, input().split()))
b = [0 for _ in range(n)]
c = []
for i in range(n-1, -1, -1):
    d = 0
    for j in range(n-1, i, -1):
        if (j+1)%(i+1) == 0:
            d += b[j]
    if d%2 != a[i]:
        b[i] = 1
        c.append(i+1)
    else:
        b[i] = 0
if c == []:
    print(0)
else:
    print(len(c))
    for i in range(len(c)):
        print(c[i], end=' ')
    print()

Submission status: Time Limit Exceeded

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

a.insert(0,0)

ans = [0]*(n+1)

for i in range(n,0,-1):
    value = 0
    for j in range(2*i,n+1):
        value = value ^ ans[j]
    ans[i] = value ^ a[i]
print(sum(ans))
for i in range(1,n+1):
    if ans[i] == 1:
        print(i,end = " ")

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
A = list(map(int,input().split()))
m = 0
ans= []
for i in reversed(range(n)):
  z = 0
  for a in ans:
    if a%(i+1)==0:
      z += 1
  if (z+A[i])%2==1:
    ans.append(i+1)
    m+= 1
  else:
    pass
print(m)
print(*ans)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

n = int(input())
a = list(map(int,input().split()))
m = 0
ans= np.array([])
for i in reversed(range(n)):
  z = np.count_nonzero(ans%(i+1)==0)
  if (z+a[i])%2==1:
    ans = np.append(ans,i+1)
    m+= 1
  else:
    pass
ans = ans.tolist()
ans = [int(i) for i in ans]
print(m)
print(*ans)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

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

B = np.zeros(N)
n = np.arange(1, N+1)
for i in range(N):
  if np.sum(B[n % n[-i-1] == 0]) % 2 != A[-i-1]:
    B[-i-1] = 1

print(int(np.sum(B)))
print(' '.join(map(str, np.where(B == 1)[0]+1)))

Submission status: Time Limit Exceeded

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

d=0
ans=[0]*N
while len(A)>1:
  for i in reversed(range((len(A)+1)//2,len(A))):
    asum=A[i]
    for j in range(len(A)+1,N+1):
      if j%(i+1)==0:
        asum+=ans[j-1]
    if asum%2==1:
      ans[i]=1
    A.pop(i)

if A[0]+sum(ans)%2==1:
  ans[0]=1
  
print(sum(ans))
_ans=[]
for i,e in enumerate(ans):
  if e==1:
    _ans.append(str(i+1))
print(" ".join(_ans))

Submission status: Time Limit Exceeded

Solution code:
import numpy as np


def solve(string):
    n, *a = map(int, string.split())
    t = np.zeros(n)
    ans = []
    for i, _a in zip(range(n, 0, -1), a[::-1]):
        s = t[i - 1::i].sum() % 2
        if s == _a:
            continue
        ans.append(str(i))
        t[i - 1] += 1
    return "0" if len(ans) == 0 else "{}\n{}".format(len(ans), " ".join(ans[::-1]))


if __name__ == '__main__':
    print(solve('\n'.join([input(), input()])))

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

n = int(input())
A = list(map(int, input().split()))
balls = np.array(A[n//2:])[::-1]
done = np.arange(n//2+1, n+1)[::-1]

for i in reversed(range(1,n//2+1)):
    a = A[i-1]
    odd_even = sum(balls[done % i == 0]) % 2
    ball = abs(a - odd_even)
    done = np.append(done, i)
    balls = np.append(balls, ball)
balls = balls[::-1]    

ans = np.where(balls==1)[0] + 1
print(len(ans))
print(*ans)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

n = int(input())
A = list(map(int, input().split()))
done = np.array([])
balls = np.array([])
for i in reversed(range(1,n+1)):
    a = A[i-1]
    odd_even = sum(balls[done % i == 0]) % 2
    ball = abs(a - odd_even)
    done = np.append(done, i)
    balls = np.append(balls, ball)
balls = balls[::-1]    

ans = np.where(balls==1)[0] + 1
print(len(ans))
print(*ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
A = [int(x) for x in input().split()]
B = [0] * n

for i in reversed(range(n)):
    if i + 1 > n // 2:
        B[i] = A[i]
        # iの倍数が書かれた箱に入っているボールの個数はOK
    else:
        # iの倍数が書かれた箱に入っているボールの個数
        c = n // (i+1)
        s = 0
        for j in range(c):
            s += B[(i+1)*(j+1)-1]
        if s % 2 == A[i]:
            continue
        else:
            B[i] = 1

print(sum(B))
for i in range(len(B)):
    if B[i] == 1:
        if sum(B[i:]) > 1:
            print(i + 1, end=' ')
        else:
            print(i + 1)

Submission status: Time Limit Exceeded

Solution code:
#!/usr/bin/env python3
import sys
import numpy as np
sys.setrecursionlimit(10 ** 7)

MOD = 2  # type: int


def solve(N: int, a: "List[int]"):
    a = np.array(a)
    ans = np.zeros(N)
    # print(ans)
    ans_idx = []
    for i in range(N - 1, -1, -1):
        # print(i)
        # print(list(range(i * 2 + 1, N, i + 1)))
        # print(ans[range(i * 2 + 1, N, i + 1)])
        # print()
        if (a[i] + ans[list(range(i * 2 + 1, N, i + 1))].sum()) % 2 == 0:
            ans[i] = 0
        else:
            ans[i] = 1
            ans_idx.append(i + 1)
    # print(ans)
    b = int(sum(ans))
    print(b)
    if b:
        print(*ans_idx)
    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools
# (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    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: Time Limit Exceeded

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

    # divisors.sort()
    return divisors


N = int(input())
A = [int(x) for x in input().split()]
ans = []
score = [0] * N

for i in range(N - 1, -1, -1):
    if score[i] % 2 != A[i]:
        ans.append(i + 1)
        divisors = make_divisors(i + 1)
        for v in divisors:
            score[v - 1] += 1



print(len(ans))
if len(ans) != 0:
    for v in ans:
        print(v, end=" ")

Submission status: Time Limit Exceeded

Solution code:
def make_divisors(n):
	divisors = [1]
	for i in range(2, int(n ** 0.5) + 1):
		if n % i == 0:
			divisors.append(i)
			if i != n // i:
				divisors.append(n // i)
	return divisors
N = int(input())
a = list(map(int, input().split()))
num = 0
ans = []
for i in range(N):
	list = make_divisors(N - i)
	if a[N - 1 - i] % 2 == 1:
		num += 1
		ans.append(N - i)
		for j in list:
			a[j - 1] += 1
print(num)
Ans = [str(x) for x in ans]
print(' '.join(Ans))

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
N = int(input())
a = [0]+list(map(int,input().split()))
ans = np.array([0]*(N+1))
an = []
for i in range(N,0,-1):
  b = [i*j for j in range(2,N//i+1)]
  #print(b)
  c = sum(ans[b])%2
  if c!=a[i]:
    ans[i]=1
    an.append(i)
print(len(an))
for i in range(len(an)):
  print(an[i],end=" ")

Submission status: Time Limit Exceeded

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

maxnum = len(a) + 1
ans = ""
anscount = 0
for i in range(len(a)-1, -1, -1):
  mod = a[i]
  now = i + 1
  count = 1
  truemod = 0
  while (True):
    if now * count < maxnum:
      truemod += b[now*count-1]
      count += 1
    else:
      break
  if truemod % 2 != mod:
    b[i] = 1
    anscount += 1
    ans += str(i+1)+ " "
print(anscount)
if anscount > 0:
  print(ans[:-1])

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
a = list(map(int,input().split()))
b = a[::-1]
c = []
for i in range(N):
    count = b[i]
    j = 2
    while (N-i)*j <= N:
        if (N-i)*j in c:
            count += 1
        j += 1
    if count%2 == 1:
        c.append(N-i)
print(len(c))
for i in range(len(c)):
    print(c[i],end=" ")

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
N = int(input())
A = [int(x) for x in input().split()]
solls = np.zeros(N)
for i in range(N):
    tmp = []
    tmp.append(solls[N-(i+1)])
    for j in range(N):
        if (j+2)*(N-(i+1)) <= (N-1):
            tmp.append(solls[(j+2)*(N-(i+1))])
    if sum(tmp)%2 != A[N-(i+1)]:
        solls[N-(i+1)] = 1

s = 0
ansint = []
for i in range(N):
    if solls[i] == 1:
        s = s+1
        ansint.append(i+1)

print(s)
print(*ansint)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
a = list(map(int,input().split()))
b = a[::-1]
c = []
for i in range(N):
    count = b[i]
    for j in c:
        if j%(N-i) == 0:
            count += 1
    if count%2 == 1:
        c.append(N-i)
print(len(c))
for i in range(len(c)):
    print(c[i],end=" ")