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
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)


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(readline())
a = list(map(int, readline().split()))
a = a[::-1]
cnt = [0] * n
ans = []
for i in range(n):
    if cnt[n - i - 1] % 2 != a[i]:
        ans.append(n - i)
        memo = make_divisors(n - i)
        for j in range(len(memo)):
            cnt[memo[j] - 1] += 1
print(len(ans))
print(*ans[::-1])

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
a=list(map(int,input().split()))
A=[0]*N
B=[]
count=0
for i in range(N//2,N):
    if a[i]==1:
        A[i]=1
        B.append(i+1)
for i in range(N//2)[::-1]:
    asum=0 
    x=i+1
    for j in range(i,N,x):
        asum=asum+A[j]
    if asum%2!=a[i]:
        A[i]=1
        B.insert(0,i+1)
count=sum(A)
print(count)
if count!=0:
    print(*B)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
a=list(map(int,input().split()))
A=[0]*N
B=[]
count=0
for i in range(N//2,N):
    if a[i]==1:
        A[i]=1
        count=count+1
        B.append(i+1)
for i in range(N//2)[::-1]:
    asum=0 
    x=i+1
    for j in range(i,N,x):
        asum=asum+A[j]
    if asum%2!=a[i]:
        A[i]=1
        B.insert(0,i+1)
        count=count+1
print(count)
if count!=0:
    print(*B)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
a=list(map(int,input().split()))
A=[0]*N
B=[]
count=0
for i in range(N)[::-1]:
    asum=0
    x=i+1
    for j in range(i,N,x):
        asum=asum+A[j]
    if asum%2==a[i]:
        A[i]=0
    else:
        A[i]=1
        B.insert(0,i+1)
        count=count+1
print(count)
if count!=0:
    print(*B)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
a=list(map(int,input().split()))
A=[0]*N
B=[]
count=0
for i in range(N//2,N):
    if a[i]==1:
        A[i]=1
        count=count+1
        B.append(i+1)
for i in range(N//2)[::-1]:
    asum=0
    x=i+1
    for j in range(i,N,x):
        asum=asum+A[j]
    if asum%2==a[i]:
        A[i]=0
    else:
        A[i]=1
        B.insert(0,i+1)
        count=count+1
print(count)
if count!=0:
    print(*B)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
a=list(map(int,input().split()))
A=[0]*N
B=[]
count=0
for i in range(N//2,N):
    if a[i]==1:
        A[i]=1
        count=count+1
        B.append(i+1)
for i in range(N//2)[::-1]:
    asum=0
    for j in range(i,N):
        if (j+1)%(i+1)==0:
            asum=asum+A[j]
    if asum%2==a[i]:
        A[i]=0
    else:
        A[i]=1
        B.insert(0,i+1)
        count=count+1
print(count)
if count!=0:
    print(*B)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
a=list(map(int,input().split()))
A=[0]*N
B=[]
count=0
for i in range(N)[::-1]:
    asum=0
    for j in range(i,N):
        asum=asum+A[j]
    if asum%2==a[i]:
        A[i]=0
    else:
        A[i]=1
        B.append(i+1)
        count=count+1
B.sort()
print(count)
if count!=0:
    print(*B)

Submission status: Time Limit Exceeded

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

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

M = sum(ans)
ans2 = []
for i in range(N):
    if ans[i] !=0:
        ans2.append(ans[i])

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

Submission status: Time Limit Exceeded

Solution code:
import sys
input = lambda: sys.stdin.readline().rstrip()
input_nums = lambda: list(map(int, input().split()))

def main():
    N = int(input())
    A = input_nums()
    idx = [i for i in range(1, N+1)]
    A = dict(zip(idx, A))
    B = dict(zip(idx,[0]*N))
    A_keys = A.keys()
    for i in reversed(range(1,N+1)):
        b = i
        cnt = 0
        while True:
            if not b in A_keys:
                break
            else:
                cnt += B[b]
            b += b
            if not cnt % 2 == A[i]:
                B[i] = 1
            else:
                B[i] = 0
    ans = []
    for k, v in B.items():
        if v == 1:
            ans.append(k)
    print(len(ans))
    if len(ans) != 0:
        print(*ans)

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
import sys
input = lambda: sys.stdin.readline().rstrip()
input_nums = lambda: list(map(int, input().split()))

def main():
    N = int(input())
    A = input_nums()
    idx = [i for i in range(1, N+1)]
    A = dict(zip(idx, A))
    B = dict(zip(idx,[0]*N))
    A_keys = A.keys()
    for i in reversed(range(1,N+1)):
        b = i
        cnt = 0
        while True:
            if not b in A_keys:
                break
            else:
                cnt += B[b]
            b += b
        if not cnt % 2 == A[i]:
            B[i] = 1
    ans = []
    for k, v in B.items():
        if v == 1:
            ans.append(k)
    print(len(ans))
    if len(ans) != 0:
        print(*ans)

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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


for i in range(n):
    cnt = 0
    baisuu = [j for j in range(1,n+1) if j % (n-i) == 0]
    for j in baisuu:
            cnt += a[j-1]
    b.append(cnt%2)

c = 0
for i in b:
    if i != 0:
        c += 1

print(c)
str_b = []
for i in reversed(b):
    if i != 0:
        str_b.append(str(i))
print(' '.join(str_b))

Submission status: Time Limit Exceeded

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


for i in range(n):
    cnt = 0
    for j in range(n):
        if (j+1) % (n-i) == 0:
            cnt += a[j]
    b.append(cnt%2)

c = 0
for i in b:
    if i != 0:
        c += 1

print(c)
str_b = []
for i in reversed(b):
    if i != 0:
        str_b.append(str(i))
print(' '.join(str_b))

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
A=list(map(int,input().split()))
M=0
X=[]
for i in range(N-1,-1,-1):
  _=0
  for j in range(i+1,N+1,i+1):
    if j in X:
      _+=1
  if A[i]==0 and _%2==1:
    M+=1
    X.append(i+1)
  elif A[i]==1 and _%2==0:
    M+=1
    X.append(i+1)
print(M)
print(*X)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
A=list(map(int,input().split()))
M=0
X=[]
for i in range(N-1,-1,-1):
  _=0
  for x in X:
    if x%(i+1)==0:
      _+=1
  if A[i]==0 and _%2==1:
    M+=1
    X.append(i+1)
  elif A[i]==1 and _%2==0:
    M+=1
    X.append(i+1)
print(M)
print(*X)

Submission status: Time Limit Exceeded

Solution code:
import sys
import numpy as np

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

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

B = np.where(answer == 1)[0]
print(len(B))
print(*B)

Submission status: Time Limit Exceeded

Solution code:
import sys

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

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

    return 0

if __name__ == "__main__":
    solve()

Submission status: Time Limit Exceeded

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

i = n
while i > 0:
    cnt = ans[i:n+1].count(1)
    if cnt % 2 != a[i-1]:
        ans[i] = 1
    i -= 1
    #print(cnt)
print(ans.count(1))
for i in range(1,n+1):
    if ans[i] == 1:
        print(i)

Submission status: Time Limit Exceeded

Solution code:
import math
import copy
from copy import deepcopy
import sys
import fractions
from functools import reduce
import heapq
 
# input = sys.stdin.readline
# sys.setrecursionlimit(10**6)
 
# ===FUNCTION===
 
def getInputInt():
    inputNum = int(input())
    return inputNum
 
 
def getInputListInt():
    outputData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]
 
    return outputData
 
 
def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)
 
    return outputDataList
 
 
def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)
 
    return outputDataList
 
 
# ===CODE===
 
n = getInputInt()
data = getInputListInt()
l = len(data)
 
ans = []
 
for i in range(l-1, -1, -1):
    cnt = 0
    for j in ans:
        if j % (i+1) == 0:
            cnt += 1
    if data[i] != cnt % 2:
        ans.append(i+1)
 
if len(ans) == 0:
    print(0)
else:
    print(len(ans))
    print(*ans, sep=" ")

Submission status: Time Limit Exceeded

Solution code:
import math
import copy
from copy import deepcopy
import sys
import fractions
import numpy as np
from functools import reduce
import statistics
import heapq

# input = sys.stdin.readline
# sys.setrecursionlimit(10**6)

# ===FUNCTION===

def getInputInt():
    inputNum = int(input())
    return inputNum


def getInputListInt():
    outputData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData


def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList


def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList


# ===CODE===

n = getInputInt()
data = getInputListInt()
l = len(data)

ans = []

for i in range(l-1, -1, -1):
    cnt = 0
    for j in ans:
        if j % (i+1) == 0:
            cnt += 1
    if data[i] != cnt % 2:
        ans.append(i+1)

if len(ans) == 0:
    print(0)
else:
    print(len(ans))
    print(*ans, sep=" ")

Submission status: Time Limit Exceeded

Solution code:
import math
import copy
from copy import deepcopy
import sys
import fractions
import numpy as np
from functools import reduce
import statistics
import heapq

# input = sys.stdin.readline
# sys.setrecursionlimit(10**6)

# ===FUNCTION===

def getInputInt():
    inputNum = int(input())
    return inputNum


def getInputListInt():
    outputData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData


def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList


def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList


# ===CODE===

n = getInputInt()
data = getInputListInt()
l = len(data)

ans = []

for i in range(l-1, -1, -1):
    cnt = 0
    for j in ans:
        if j % (i+1) == 0:
            cnt += 1
    if data[i] != cnt % 2:
        ans.append(i+1)

if len(ans) == 0:
    print(0)
else:
    print(len(ans))
    print(*ans, sep=" ")

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = list(map(int,input().split()))
ball = [0] * N

for i in range(N - 1,-1,-1):
  boxes = sum([ball[j] for j in range(N) if j % (i + 1) == 0]) % 2
  if A[i] != boxes:
    ball[i] += 1

if sum(ball) == 0:
  print(0)
else:
  M = sum(ball)
  ball = [i for i in ball if i == 1]
  print(M)
  print(*ball)

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
N = int(input())
A = list(map(int, input().split()))
A.reverse()
B = [0 for i in range(N)]
for i in range(N):
    tmp = 0
    for j in range(i):
        tmp += B[j]
    if A[i] % 2 != tmp % 2:
        B[i] = 1
B.reverse()
ans = []
M = sum(B)
for i in range(N):
    if B[i] == 1:
        ans.append(i+1)
print(M)
print(*ans)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
A=list(map(int,input().split()))
B=['0']*N
ret1=0
ret2=''
for i in range(N, 0, -1):
  Bit='0'*i+('0'*(i-1)+'1')*(N//i)
  Bit=int(Bit[:N], 2)
  BBit=int(''.join(B), 2)
  if bin(BBit & Bit).count('1')%2 ^ A[i-1]:
    ret1+=1
    B[i-1]='1'
    ret2=str(i)+' '+ret2
print(ret1)
print(ret2)

Submission status: Time Limit Exceeded

Solution code:
import sys
sys.setrecursionlimit(10 ** 6)


def input():
    return sys.stdin.readline()[:-1]


def main():
    N = int(input())
    a = [-1]+list(map(int, input().split()))
    b = [0] * (N+1)
    for i in reversed(range(1,N+1)):
        total = 0
        for j in range(i,N+1):
            if i%j==0:
                total += b[j]
        if a[i] != (total%2):
            b[i] = 1
    ans = []
    cnt = 0
    for i, n in enumerate(b):
        if n!=0:
            ans.append(i)
            cnt += 1
    print(cnt)
    print(*ans)

if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

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

def main():
	N = int(input())
	a = list(map(int,input().split()))
	ball = []
	ballNum = 0
	f = [0]*N

	for i in reversed(range(N)):
		if (sum(filter(lambda x: x % (i+1) == 0, f)) % 2) != (a[i] % 2):
			f[i] = 1
			ball.append(i+1)
			ballNum +=1

	print(ballNum)
	print(*ball)

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 = list(map(int, input().split()))

cnt_list = [0] * N
M = 0
ans_list = []
for i in range(N-1, -1, -1):
    if A[i] == 1 and cnt_list[i] % 2 == 0:
        M += 1
        ans_list.append(i+1)
        tmp_list = make_divisors(i+1)
        for t in tmp_list:
            cnt_list[t-1] += 1
    elif A[i] == 1 and cnt_list[i] % 2 == 1:
        pass
    elif A[i] == 0 and cnt_list[i] % 2 == 0:
        pass
    else:
        M += 1
        ans_list.append(i+1)
        tmp_list = make_divisors(i+1)
        for t in tmp_list:
            cnt_list[t-1] += 1
print(M)
if M == 0:
    exit()
print(" ".join(map(str, ans_list)))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import sys
def input():
  return sys.stdin.readline()[:-1]

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

for i in range(n-1):
  if a[n-1-i]&1:
    b.add(n-i)
    for j in range(2, int((n-i)**0.5)+1):
      if (n-i)%j == 0:
        a[j-1] += 1
        if (n-i)//j != j:
          a[(n-i)//j -1] += 1
if a[0] != len(b)%2:
  b.add(1)
          
print(len(b))
if len(b)>0:
  print(*b)

Submission status: Time Limit Exceeded

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

for i in range(n-1):
  if a[n-1-i]&1:
    b.add(n-i)
    for j in range(2, int((n-i)**0.5)+1):
      if (n-i)%j == 0:
        a[j-1] += 1
        if (n-i)//j != j:
          a[(n-i)//j -1] += 1
if a[0] != len(b)%2:
  b.add(1)
          
print(len(b))
if len(b)>0:
  print(*b)

Submission status: Time Limit Exceeded

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

for i in range(n-1):
  if a[n-1-i]%2 == 1:
    b.add(n-i)
    for j in range(2, int((n-i)**0.5)+1):
      if (n-i)%j == 0:
        a[j-1] += 1
        if (n-i)//j != j:
          a[(n-i)//j -1] += 1
if a[0] != len(b)%2:
  b.add(1)
          
print(len(b))
if len(b)>0:
  print(*b)

Submission status: Time Limit Exceeded

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

for i in range(n):
  if a[n-1-i]%2 == 1:
    b.add(n-i)
    for j in range(1, int((n-i)**0.5)+1):
      if (n-i)%j == 0:
        a[j-1] += 1
        if (n-i)//j != j:
          a[(n-i)//j -1] += 1

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

Submission status: Time Limit Exceeded

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

for i in range(n):
  if a[n-1-i] != c[n-1-i]%2:
    b.add(n-i)
    for j in range(1, int((n-i)**0.5)+1):
      if (n-i)%j == 0:
        c[j-1] += 1
        if (n-i)//j != j:
          c[(n-i)//j -1] += 1

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

Submission status: Time Limit Exceeded

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

for i in range(n):
  if a[n-1-i] ^ c[n-1-i]:
    b.add(n-i)
    for j in range(1, int((n-i)**0.5)+1):
      if (n-i)%j == 0:
        c[j-1] = c[j-1]^1
        if (n-i)//j != j:
          c[(n-i)//j -1] = c[(n-i)//j -1]^1

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

Submission status: Time Limit Exceeded

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

for i in range(n):
  if a[n-1-i] ^ c[n-1-i]%2:
    b.add(n-i)
    for j in range(1, int((n-i)**0.5)+1):
      if (n-i)%j == 0:
        c[j-1] = c[j-1]^1
        if (n-i)//j != j:
          c[(n-i)//j -1] = c[(n-i)//j -1]^1

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

Submission status: Time Limit Exceeded

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

for i in range(n):
  if a[n-1-i] ^ c[n-1-i]%2:
    b.add(n-i)
    for j in range(1, int((n-i)**0.5)+1):
      if (n-i)%j == 0:
        c[j-1] += 1
        if (n-i)//j != j:
          c[(n-i)//j -1] += 1

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

Submission status: Time Limit Exceeded

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

for i in range(n):
  if a[n-1-i] ^ c[n-1-i]%2:
    b.add(n-i)
    for j in range(1, int((n-i)**0.5)+1):
      if (n-i)%j == 0 and j**2 != n-i:
        c[j-1] += 1
        c[(n-i)//j -1] += 1
      elif j**2 == n-i:
        c[j-1] += 1

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

Submission status: Time Limit Exceeded

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

Solution code:

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

ans = []

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

  for m in [n for n in range(j, N+1) if (n % j == 0) and (n != j) ]:
    cnt += A[N - m]
  
  if (cnt + A[i]) % 2 == 1:
    ans.append(j)

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

Submission status: Time Limit Exceeded

Solution code:

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

ans = []

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

  for m in [n for n in range(1, N+1) if (n % j == 0) and (n != j) ]:
    cnt += A[N - m]
  
  if (cnt + A[i]) % 2 == 1:
    ans.append(j)

len_ans = len(ans)
if len_ans == 0:
  print(0)
else:
  print(len_ans)
  print(*ans)

Submission status: Time Limit Exceeded

Solution code:
import sys
sys.setrecursionlimit(4100000)
def input():
    return sys.stdin.readline().rstrip()

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

Submission status: Time Limit Exceeded

Solution code:
import sys
sys.setrecursionlimit(4100000)

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

Submission status: Time Limit Exceeded

Solution code:
import sys
sys.setrecursionlimit(4100000)

N = int(input())
a = list(map(int, input().split()))
b = []
if N > 10 ** 5:
  for i in range(N, 10 ** 5, -1):
    if a[i - 1] == 1:
      b.append(i)
for i in range(min(10 ** 5, N), 0, -1):
  j = i * 2
  s = a[i - 1]
  while j <= N:
    if j in b:
      s += 1
    j += i
  if s % 2 == 1:
  	b.append(i)
print(len(b))
print(*b)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
a = list(map(int, input().split()))
b = []
if N > 10 ** 5:
  for i in range(N, 10 ** 5, -1):
    if a[i - 1] == 1:
      b.append(i)
for i in range(min(10 ** 5, N), 0, -1):
  j = i * 2
  s = a[i - 1]
  while j <= N:
    if j in b:
      s += 1
    j += i
  if s % 2 == 1:
  	b.append(i)
print(len(b))
b = list(map(str, b))
print(" ".join(b))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import sys
input = sys.stdin.readline
N=int(input())
a=list(map(int,input().split()))
a0 = a[0]
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
ma = N
mi = N//2
for i in range(len(bin(N))-2):
    for j in range(ma,mi,-1):
        if a[j-1]%2==1:
            tg_list = make_divisors(j)
            for k in tg_list:
                if k!=j:
                    a[k-1] += 1
    #a[mi//2:mi] %= 2
    #print(a)
    ma = mi
    mi = mi//2
if sum(a)%2 == a0:
    #print(a)
    res = [str(i+1) for i in range(N) if a[i]%2==1]
    M = len(res)
    print(M)
    if M!=0:
        print(' '.join(res))
else:
    print(-1)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
N=int(input())
a=np.array(list(map(int,input().split())))
a0 = a[0]
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
ma = N
mi = N//2
for i in range(len(bin(N))-2):
    for j in range(ma,mi,-1):
        if a[j-1]==1:
            tg_list = make_divisors(j)
            for k in tg_list:
                if k!=j:
                    a[k-1] += 1
    a %= 2
    #print(a)
    ma = mi
    mi = mi//2
if sum(a)%2 == a0:
    #print(a)
    res = [str(i+1) for i in range(N) if a[i]==1]
    print(len(res))
    if len(res)!=0:
        print(' '.join(res))
else:
    print(-1)

Submission status: Time Limit Exceeded

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

n = int(input())

a = list(map(int, input().split()))
#print(a)

ans = []

a = a[::-1]

for i, x in enumerate(a):
  j = n-i
  tmp = 0
  
  k = 1
  
  baisu = [(n//j) * k for k in range(n//j)]
  
  for k in range(n//j):
    if (k+1) * j in ans:
	    tmp += 1
    
  if tmp % 2 != x:
    ans.append(j)

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

Submission status: Time Limit Exceeded

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

n = int(input())

a = list(map(int, input().split()))
#print(a)

ans = []

a = a[::-1]

for i, x in enumerate(a):
  j = n-i
  tmp = 0
  
  k = 1
  
  for k in range(n//j):
    if (k+1) * j in ans:
	    tmp += 1
    k += 1
    
  if tmp % 2 != x:
    ans.append(j)

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

Submission status: Time Limit Exceeded

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

n = int(input())

a = list(map(int, input().split()))
#print(a)

ans = []

for i, x in enumerate(a[::-1]):
  j = n-i
  tmp = 0
  
  k = 1
  
  for k in range(n//j):
    if (k+1) * j in ans:
	    tmp += 1
    k += 1
    
  if tmp % 2 != x:
    ans.append(j)

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

Submission status: Time Limit Exceeded

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

n = int(input())

a = list(map(int, input().split()))
#print(a)

ans = []

for i, x in enumerate(a[::-1]):
  j = n-i
  tmp = 0
  
  k = 1
  
  while k * j <= n:
    if k * j in ans:
	    tmp += 1
    k += 1
    
  if tmp % 2 != x:
    ans.append(j)

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

a = list(map(int, input().split()))
#print(a)

ans = []

for i, x in enumerate(a[::-1]):
  j = n-i
  tmp = 0
  
  k = 1
  
  while k * j <= n:
    if k * j in ans:
	    tmp += 1
    k += 1
    
  if tmp % 2 != x:
    ans.append(j)

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

Submission status: Time Limit Exceeded

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

B = [0] * N
for i in reversed(range(N)):
    ball = 0
    base = i + 1

    for j in range(1, N + 1):
        if ball * j - 1 >= N:
            break
        ball += B[ball * j - 1]

    if ball % 2 != A[i]:
        B[i] = 1

print(sum(B))
print(*[i for i, b in enumerate(B, start=1) if b == 1], sep=' ')

Submission status: Time Limit Exceeded

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

boxes=[0]*n #if ball in boxes[i-1]=boxes no.i
b=[]
#m=len(b)
i=n #iの番号が書いた箱、インデックスはa[i-1]について
while i>=1:
	count=a[i-1]
	for j in range(i+1,n+1):
		if j%i==0:
			count+=boxes[j-1]
	boxes[i-1]=count%2
	if boxes[i-1]:
		b.append(i)
	i-=1
#print(boxes)

print(len(b))
print(*b) #space区切り

Submission status: Time Limit Exceeded

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

boxes=[0]*n #if ball in boxes[i-1]=boxes no.i
#b=[]
#m=len(b)
i=n #iの番号が書いた箱、インデックスはa[i-1]について
while i>=1:
	count=a[i-1]
	for j in range(i+1,n+1):
		if j%i==0:
			count+=boxes[j-1]
	boxes[i-1]=count%2
	i-=1
#print(boxes)

b=[]
for i in range(n):
	if boxes[i]==1:
		b.append(i+1)
print(len(b))
print(*b)

Submission status: Time Limit Exceeded

Solution code:
from itertools import islice


N = int(input())
A = list(map(int, input().split()))
B = [0] * N

for i in range(N - 1, 0, -1):
    p = A[i]
    for j in islice(A, i * 2, N, i):
        p ^= j
        B[i] = p ^ A[i]

B[0] = A[0] ^ (sum(B) % 2)


S = []
for i, b in enumerate(B):
    if b == 1:
        S.append(str(i + 1))

if len(S) == 0:
    print(0)
else:
    print(len(S))
    print(' '.join(S))

Submission status: Time Limit Exceeded

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

for i in range(n,0,-1):
    if a[i-1] == 1: 
        ball.append(i)
        for j in range(1,int(i**0.5//1)+1):
            if i%j == 0:
                a[j-1] = 0 if a[j-1] == 1 else 1
                if i/j != j: 
                    a[i//j-1] = 0 if a[i//j-1] == 1 else 1

m = len(ball)
print(m)
if m != 0:
    for b in ball:
        print(b,end=" ")
    else:
        print("")

Submission status: Time Limit Exceeded

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

for i in reversed(range(1,n+1)):
    if a[i-1] == 1: 
        ball.append(i)
        for j in range(1,int(i**0.5//1)+1):
            if i%j == 0:
                a[j-1] = 0 if a[j-1] == 1 else 1
                if i/j != j: 
                    a[i//j-1] = 0 if a[i//j-1] == 1 else 1

m = len(ball)
print(m)
if m != 0:
    for b in ball:
        print(b,end=" ")
    else:
        print("")

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)
        a = cnt % 2
        C[j] = a ^ A[j]

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


main()