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: Runtime Error

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

box_num = int(input())
ball_in_box_num_list = [[int(i), []] for i in input().split(" ")]
for i in range(1, box_num + 1):
    k = 2
    while i * k <= box_num:
        ball_in_box_num_list[i * k - 1][1].append(i - 1)
        k += 1
ans_num = 0
ans_list = []
for i in range(box_num):
    a = box_num - 1 - i
    b = ball_in_box_num_list[a]
    if b[0] == 1:
        ans_num += 1
        ans_list.append(a + 1)
        for j in b[1]:
            ball_in_box_num_list[j] = 1 - ball_in_box_num_list[j]
print(ans_num)
if ans_list != 0:
    ans_list = [str(i) for i in ans_list]
    ans_list = ans_list[::-1]
    print(" ".join(ans_list))

Submission status: Runtime Error

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

box_num = int(input())
ball_in_box_num_list = [[int(i), []] for i in input().split(" ")]
for i in range(1, box_num + 1):
    k = 2
    while i * k <= box_num:
        ball_in_box_num_list[i * k - 1][1].append(i)
        k += 1
ans_num = 0
ans_list = []
for i in range(box_num):
    a = box_num - 1 - i
    b = ball_in_box_num_list[a]
    if b[0] == 1:
        ans_num += 1
        ans_list.append(a + 1)
        for j in b[1]:
            ball_in_box_num_list[j] = 1 - ball_in_box_num_list[j]
print(ans_num)
if ans_list != 0:
    ans_list = [str(i) for i in ans_list]
    ans_list = ans_list[::-1]
    print(" ".join(ans_list))

Submission status: Runtime Error

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

b = [0] * (N + 1)
half = int(N / 2)
b[half:] = A[half - 1:]
for i in range(N, 0, -1):
    s = sum([b[j] for j in range(i * 2, N + 1, i)]) % 2
    if s != A[i - 1]:
        b[i] = 1
s = sum(b)
if s % 2 != A[0]:
    b[1] = 1
    s += 1
print(s)
for i, b_ in enumerate(b):
    if b_ == 1:
        print(i, end=" ")

Submission status: Runtime Error

Solution code:
import math
n = int(input())
a = list(map(int,input().split()))
b = [0]*n
itr = n
ans=0
for i in range(n):
    if (a[itr-1] + b[itr-1])%2 != 0:
        ans += 1
        m = int(math.sqrt(itr))
        for j in range(m):
            if itr%(j+1) == 0:
                b[j] += 1
                if itr != 1:
                    b[itr//(j+1)] += 1
    itr -= 1
print(ans)
for i in range(n):
    if b[i]%2 == 0:
        print(0,end=" ")
    else:
        print(1,end=" ")

Submission status: Runtime Error

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

for i in range(n-1,-1,-1):
    if(i>=n/2):
        b[i]=a[i]
    else:
        for j in range(1,n):
            if(j*i>n):
                break
            else:
                cnt += b[i*j]%2
        if(cnt==a[i]):
            b[i]=0
        elif(cnt!=a[i]):
            b[i]=1

for i in range(n):
    m += b[i]
print(m)
for k in range(n):
    if(b[k]==1):
        print(k+1,end=" ")

Submission status: Runtime Error

Solution code:
m = int(input())
s = list(map(int, input()))
bs = [0] * m

cnt = 0
for i in range(m, 0, -1):
  b = sum(list(map(lambda x: bs[x-1], list(range(i, m+1, i)))))
  if s[i-1] is 0:
    if  b%2 is 0:
      bs[i-1] = 0
    else:
      cnt += 1
      bs[i-1] = 1
  else:
    if  b%2 is 0:
      cnt += 1
      bs[i-1] = 1
    else:
      bs[i-1] = 0

print(cnt)
print("".join(map(str, bs)))

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import math

# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    N = inputInt()
    A = inputList()
    
    ans = [0 for i in range(N)]
    ans_cnt = 0
    ans_str = ""
    for i in range(N, 0, -1):
        cons = 0
        for j in range(i, N+1, i):
            cnt ^= ans[j-1]
        if A[i-1] == 1 and cons % 2 == 0:
            ans[i-1] = 1
            ans_cnt += 1
            ans_str = ans_str + str(i) + " "
            continue
        if A[i-1] == 0 and cons % 2 == 1:
            ans[i-1] = 1
            ans_cnt += 1
            ans_str = ans_str + str(i) + " "
            continue
            
    print(ans_cnt)
    print(ans_str)
            	
if __name__ == "__main__":
	main()

Submission status: Runtime Error

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

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

s = sum(A[0:N])
print(s)

n = 1
for i in range(N):
    if s == 0:
        print('')
        break
    if A[i] == 1:
        if n == s:
            print(i+1)
            break
        else:
            print(i+1,end=' ')
            n += 1

Submission status: Runtime Error

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

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

s = sum(A[0:N])
print(s)

n = 1
for i in range(N):
    if s == 0:
        print('')
    if A[i] == 1:
        if n == s:
            print(i+1)
            break
        else:
            print(i+1,end=' ')
            n += 1

Submission status: Runtime Error

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

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

print(sum(A[0:N]))

n = 1
for i in range(N):
    if A[i] == 1:
        if n == sum(A[0:N]):
            print(i+1)
        else:
            print(i,end=' ')
            n += 1

Submission status: Runtime Error

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


for i in range(1,N+1):
    cnt=0
    n=N+1-i
    for j in range(1,10**5):
        #print(n,n*j)
        if n*j>N:
            break
        else:
            if B[n*j]==1:
                cnt+=1
    if cnt%2!=A[n]:
        B[n]+=1
        ans.append(n)
ans.sort()
print(len(ans))
print(*ans)

Submission status: Runtime Error

Solution code:
N = int(input())
a = map(int, input().split())
a = [0] + list(a)
b = [0 for i in range(N+1)]
result_str = ''

for i in range(N, 0, -1):
  i_sum = 0
  for j in range(1, N // i + 1):
    i_sum += b[j*i]
  if i_sum % 2 != a[i]:
    b[i] = 1
	result_str = '{}　'.format(i)　+ result_str
  
print(sum(b))
print(result_str[:-1])

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import math

# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev
 
def main():
    N = int(input())
    A = input().split()
    
    ans = []
    hafe = N // 2
    for i in range(N, 0, -1):
        if i >= hafe:
            if A[i-1] == "1":
                ans.append(i)
            continue
            
        cons = 0
        '''
        for j in range(i, N+1, i):
            if j in ans:
                cons += 1
        if A[i-1] == "1" and cons % 2 == 0:
            ans.append(i)
            continue
        if A[i-1] == "0" and cons % 2 == 1:
            ans.append(i)
            continue
            '''
            
    print(len(ans))
    if len(ans) != 0:
        anss = ""
        for i in ans:
            anss = anss + str(i) + " "
        
            print(anss[:-1])
            	
if __name__ == "__main__":
	main()

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import math

# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev
 
def main():
    N = int(input())
    A = input().split()
    
    ans = []
    hafe = N // 2
    for i in range(N, 0, -1):
        if i >= hafe:
            if A[i-1] == "1":
                ans.append(i)
            continue
            
        cons = 0
        for j in range(i, N+1, i):
            if j in ans:
                cons += 1
        if A[i-1] == "1" and cons % 2 == 0:
            ans.append(i)
            continue
        if A[i-1] == "0" and cons % 2 == 1:
            ans.append(i)
            continue
            
    print(len(ans))
    if len(ans) != 0:
        anss = ""
        for i in ans:
            anss = anss + str(i) + " "
        
            print(anss[:-1])
            	
if __name__ == "__main__":
	main()

Submission status: Runtime Error

Solution code:
def main13():
    n = int(input())
    a = input().split()
    nlist = []
    for i in range(n):
        nlist.append(int(a[i])
    resultlist = []
    for i in range(n):
        resultlist.append(0)
    for i in range(n-1,-1,-1):
        kaisu = int(n / (i+1))
        if kaisu == 1:
            resultlist[i] = nlist[i]
        else:
            kari = 0
            
            for j in range((i+1)*2-1,n,(i+1)):
                kari = kari + resultlist[j]
            kari = kari % 2
            if (kari + nlist[i]) == 0:
                resultlist[i] = 0
            else:
                resultlist[i] = 1
    print(resultlist.count(1))
    for i in range(n):
        if resultlist[i] == 1:
            print((i+1) ,end='')
            print(" " ,end='')
    print("")  

if __name__ == "__main__":
    main13()

Submission status: Runtime Error

Solution code:
n = int(input())
a = list(map(int,input().split()))
ball = [0 for i in range(n)]
count = 0 #ボールが入ってる箱の数
index = [] #ボールが入ってる番号

for i in range(n-1, -1, -1):
    balls = 0
    j = i
    while j < n:
        j += i + 1
        balls += ball[j]
    
    if a[i] != balls%2:
        a[i] = 1
        count += 1
        index.append(i+1)
        
ans = ""
for i in range(len(index)):
    if i < len(index)-1:
        ans += str(index[i]) + " "
    else:
        ans += str(index[i])
print(count)
print(ans)

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-


def main():
    n = int(input())
    a = [int(input()) for _ in range(n)]
    sorted_a = sorted(a)
    a_max = max(a)
    a_second = sorted_a[-2]

    for ai in a:
        if ai == a_max:
            print(a_second)
        else:
            print(a_max)


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
n = int(input())
a = list(map(int,input().split()))
ball = [0 for i in range(n)]
count = 0
index = []

for i in range(n-1, (n+1)//2 -1, -1):
    if a[i] == 1:
        ball[i] = 1
        count += 1
        index.append(i+1)
for i in range((n+1)//2, -1, -1):
    if ball[i + (i+1)] % 2 != a[i]:
        ball[i] = ball[i + (i+1)] + 1
        count += 1
        index.append(i+1)
    else:
        ball[i] = ball[i + (i+1)]
        
ans = ""
for i in range(len(index)):
    if i < len(index)-1:
        ans += str(index[i]) + " "
    else:
        ans += str(index[i])
print(count)
print(ans)

Submission status: Runtime Error

Solution code:
n = int(input())
a = list(map(int,input().split()))
ball = [0 for i in range(n)]
count = 0
index = []

for i in range(n-1, (n+1)//2 +1 , -1):
    if a[i] == 1:
        ball[i] = 1
        count += 1
        index.append(i+1)
for i in range((n+1)//2, -1, -1):
    if ball[i + (i+1)] % 2 != a[i]:
        ball[i] = ball[i + (i+1)] + 1
        count += 1
        index.append(i+1)
    else:
        ball[i] = ball[i + (i+1)]
        
ans = ""
for i in range(len(index)):
    if i < len(index)-1:
        ans += str(index[i]) + " "
    else:
        ans += str(index[i])
print(count)
print(ans)

Submission status: Runtime Error

Solution code:

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

M = 0
ans_lst = [0] * N

t = 0
for i in range(N-1, -1, -1):
    t = sum(ans[i::i+1])
        
    if t % 2 != a_lst[i]:
        ans_lst[i] = 1
    


m = 0
for i in range(N):
    m += ans_lst[i]
    


print(m)
ans_str = ""
for i in range(N):
    if ans_lst[i] == 1:
        ans_str += str(i+1) + " "
print(ans_str)

Submission status: Runtime Error

Solution code:

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

M = 0
ans_lst = [0] * N

t = 0
for i in range(N, -1, -1):
    t = 0
    for j in range(2*i, N, i+1):
        t += ans_lst[j]
        
    if (t + 1) % 2 == a_lst[i]:
        ans_lst[i] = 1
    


m = 0
for i in range(N):
    m += ans_lst[i]
    


print(m)
ans_str = ""
for i in range(N):
    if ans_lst[i] == 1:
        if i != 0:
            ans_str += " "
        ans_str += str(i+1)
print(ans_str)

Submission status: Runtime Error

Solution code:
n=int(input())
a=list(map(int,input().split()))
b=[0 for i in range(n)]
c=0
d=[]
for i in range(n-1,-1,-1):
  j=2
  c=b[i]
  while((i+1)*j<=n):
    c=c^b[(i+1)*j-1]
    j+=1
  if (c!=a[i]):
    b[i]=1
  c=0
  j=2
print('{0}'.format(sum(b)))
e=list(map(str,b))
for i in range(n):
  if(b[i]==1):
    d.append(i+1)
f=' '.join(d)
print('{0}'.format(f))

Submission status: Runtime Error

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

for i in range(N+1, 0, -1):
    tmp = 0
    j = i
    while j < N+1:
        tmp += A[j]
        j += i
    A[i] = tmp % 2
ans = []
for i, j in enumerate(A):
    if j == 1:
        ans.append(i)

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

Submission status: Runtime Error

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

for i in range(N-1, 0, -1):
    tmp = 0
    for t in range(i, N+1, i):
        tmp += A[t]
    if tmp % 2 == i:
        break

ret = []
for i in range(1, tmp+1):
    if i % tmp == 0:
        ret.append(i)
print(len(ret))
print(*ret)

Submission status: Runtime Error

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

for i in range(N-1, 0, -1):
    tmp = 0
    for t in range(i, N+1, i):
        tmp += A[t]
    if tmp % 2 == i:
        break

print(tmp)
for i in range(1, tmp+1):
    if i % tmp == 0:
        print(i)

Submission status: Runtime Error

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

for i in range(N-1, 0, -1):
    tmp = 0
    for t in range(i, N+1, i):
        tmp += A[t]
    if tmp == i % 2:
        break

print(tmp)
for i in range(1, tmp+1):
    if i % tmp == 0:
        print(i)

Submission status: Runtime Error

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

for i in range(N-1, 0, -1):
    tmp = 0
    for t in range(i, N+1, i):
        tmp += A[t]
    if tmp == i:
        break

print(tmp)
for i in range(1, tmp+1):
    if i % tmp == 0:
        print(i)

Submission status: Runtime Error

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

for i in range(N-1, 0, -1):
    tmp = 0
    for t in range(i, N, i):
        tmp += A[t]
    if tmp == i:
        break

print(tmp)
for i in range(1, tmp+1):
    if i % tmp == 0:
        print(i)

Submission status: Runtime Error

Solution code:
N = int(input())
arr = [0] + map(int, input().split(' ')) #ずらしておく。
for i in range(N//2, 0, -1):
  arr[i] = sum(arr[i::i]) % 2
ans = [i for i, j in enumerate(arr) if j == 1]
print(len(ans))
print(*ans)

Submission status: Runtime Error

Solution code:
N = int(input())
arr = map(int, input().split(' '))
for i in range(N//2, 0, -1):
  arr[i] = sum(arr[i::i]) % 2
ans = [i for i, j in enumerate(arr) if j == 1]
print(len(ans))
print(*ans)

Submission status: Runtime Error

Solution code:
N = int(input())
arr = map(int, input().split())
for i in range(N//2, 0, -1):
  arr[i] = sum(arr[i::i]) % 2
ans = [i for i, j in enumerate(arr) if j == 1]
print(len(ans))
print(*ans)

Submission status: Runtime Error

Solution code:
N = int(input())
arr = map(int, input().split())
for i in range(n//2, 0, -1): # n // 2 より大きい場合はarrの値そのままでよい。
  arr[i] = sum(arr[i::i]) % 2 # それ以外はパリティをあわせる。
ans = [i for i, j in enumerate(arr) if j == 1]
print(len(ans))
print(*ans)

Submission status: Runtime Error

Solution code:
N = int(input())
arr = map(int, input().split())
for i in range(n//2, 0, -1): # n // 2 より大きい場合はarrの値そのままでよい。
  arr[i] = sum(arr[i::i]) % 2 # それ以外はパリティをあわせる。
  ans = [i for i, j in enumerate(arr) if j == 1]
print(len(ans))
print(*ans)

Submission status: Runtime Error

Solution code:

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



NumValid = [True] * (N+1)
ans = []
NumAns = [0] * (N+1)


for i in reversed(range(1,N+1)):
    j = 2 * i
    tmp = 0
    while j < N+1:
        tmp += NumAns[j]
        j += i
        
    if tmp % 2 == 0:
        if A[i] == 0:
            NumAns[i] = 0
        else:
            NumAns[i] = 1
            ans.append(i)
    else:
        if A[i] == 0:
            NumAns[i] = 1
            ans.append(i)
        else:
            NumAns[i] = 0
        
print(len(ans))
print(ans)

Submission status: Runtime Error

Solution code:
N=int(input())
arr=map(int, input().split())
for i in range(N,0,-1):
    arr[i-1] = sum(arr[i-1::i]) % 2
print(sum(arr))
print(' '.join([str(i+1) for i,j in enumerate(arr) if j == 1]))

Submission status: Runtime Error

Solution code:
N=int(input())
arr=map(int, input().split())
for i in range(n,0,-1):
    arr[i-1] = sum(arr[i-1::i]) % 2
print(sum(arr))
print(' '.join([str(i+1) for i,j in enumerate(arr) if j == 1]))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:

n = int(input())

an = list( map(int,input().split()) )

#mid = n//2 + n%2

ans = [0]*n
for i, a in enumerate(an[::-1]):

#    ta = [x for ii,x in enumerate(an[i:]) if i % (n-(ii+i)) == 0]
#    t = sum(ta)
#    print(ta,t,i,a)
#    ans[-i] = t%2

    ans[-i] = sum([x for ii, x in enumerate(an[i::i]) if i % (n-(ii+i)) == 0])%2

m = sum(ans)
print(m)

if m > 0:
    print(*[x for x in ans if x >0])

Submission status: Runtime Error

Solution code:
import bisect as bs
N = int(input())
A = [int(input()) for _ in range(N)]
def LDS(a):
    N = len(a)
    INF = float("inf")
    dp = [-INF]*N
    dp[N-1] = a[0]
    for i in range(1, N):
        j = bs.bisect_left(dp, a[i])-1
        dp[j] = a[i]
    for i in range(N-1, -1, -1):
        if dp[i] == -INF:
            return N-i-1
    return N
print(LDS(A))

Submission status: Runtime Error

Solution code:
import bisect as bs
N = int(input())
A = [int(input()) for _ in range(N)]
def LDS(a):
    N = len(a)
    INF = float("inf")
    dp = [-INF]*N
    dp[N-1] = a[0]
    for i in range(1, N):
        j = bs.bisect_left(dp, a[i])-1
        print(j)
        dp[j] = a[i]
    for i in range(N-1, -1, -1):
        if dp[i] == -INF:
            return N-i-1
    return N
print(LDS(A))

Submission status: Runtime Error

Solution code:
def d_preparing_boxes(N, A):
    balls = [0] * N

    for i in range(N, 0, -1):
        t = i
        while t <= N:
            if balls[i - 1] % 2 != A[i - 1]:
                balls[i - 1] += 1
            t += i
    ans = [k for k, b in enumerate(balls, 1) if b != 0]
    return '\n'.join(map(str, (len(ans), *ans))) if len(ans) != 0 else 0

N = int(input())
A = [int(i) for i in input().split()]
print(d_preparing_boxes(N, A))

Submission status: Runtime Error

Solution code:
#素数判定
N=int(input())
A=[int(i) for i in input().split()]
n=2
com=""
if A[0]=0:
	if A.count("1")==0:
		print("0")
	else:
		print("-1")
else:
	if A.count("1")>2:print("-1")
	elif A.count("1")==1:
		print("1")
		print("1")
	else:
		A[0]=int("0")
		p=A.index("1")
		while True:
			if p%n==0:
				print("-1")
				break
			n+=1
			if p//2+1>n:
				print("2")
				for i in range(N):
					if i==p or i==1:
						com+=1+" "
					else:
						com+=0+" "
				print(com)
				break

Submission status: Runtime Error

Solution code:
N = int(input())
A = list(map(int, input().split()))
for i in range(N//2, -1, -1):
  sum = 0
  for o in range(1, (N//o)+1):
    sum += A[i*o-1]
  A[i] = sum%2
  
print(A.count(1))
ans = [str(q) for q,w in zip(range(N), A) if w == 1]
print(" ".join(ans))

Submission status: Runtime Error

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

hako = [0] * (N+1)

for i in range(1,N+1)[::-1]:
    if i > N / 2:
        if a[i-1] == 1:
            hako[i] = a[i-1]
    else:
        count = 0
        for j in range(i+1,N+1,j):
            if j%i == 0:
                count += a[j-1]

        if count % 2 == a[i-1]:
            hako[i] = 0
        else:
            hako[i] = 1

print(sum(hako))

if sum(hako):
    ans = []
    for i, bin in enumerate(hako):
        if bin:
            ans.append(i)
    print(*ans)

Submission status: Runtime Error

Solution code:
N = int(input())
A = list(map(int, input().split()))
A_0 = A[0]
for i in range(N, 0, -1):
    ans = A[i-1]
    for o in range(1, int(i ** 0.5) + 1):
        if i%o == 0:
            A[o-1]  = (A[o-1] + ans)//2
            if o != i//o:
                A[(i//o) - 1] = (A[(i//o) - 1] + ans)//2
if ans[0] != A_0:
    print(-1)
else:
    print(ans.count(1))
    [print(q) for q, w in zip(range(1, N+1), ans) if w == 1]

Submission status: Runtime Error

Solution code:
N = int(input())
A = list(map(int, input().split()))
A_0 = A[0]
for i in range(N, 0, -1):
    ans = A[i-1]
    for o in range(1, int(i ** 0.5) + 1):
        if i%o == 0:
            A[o-1]  = (A[o-1] + ans)//2
            if o != i//o:
                A[(i//o) - 1] = (A[(i//o) - 1] + ans)//2
 
if ans[0] != A_0:
    print(-1)
else:
    print(ans.count(1))
    [print(q) for q, w in zip(range(1, N+1), ans) if w == 1]

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:


def sol(i,want):
    num=N//(i+1)
    wa=A[i]

    for j in range(num):
        wa+=A[(i+1)+j*(i+1)-1]
#         print(i+j*i)
#     print(i,wa,A[i])
    wa=wa%2
#     print(i,wa,A[i])
    
    if wa==want:
        x=0
    else:
        x=1
#     print(num)
    return x 

B=A[:]
half=N//2
for i in range(half):
    j=half-1-i
#     print(sol(j,A[j]))
    B[j]=sol(j,A[j])
    
C=[i+1 for i, x in enumerate(B) if x ==1]

m=sum(B)
print(m)
print(*C)

Submission status: Runtime Error

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

for i in range(n):
	j = n - 1 - i
    k = (j + 1) + (j + 1)
	if :k > n
		if a[j] == 1:
			ans.append(j+1)
	else:
		count = 0
		while k <= n:
			if k in ans:
				count = count + 1
			k = k + (j + 1)
		count_01 = count % 2
		if a[j] == 0:
			if count_01 == 1:
				ans.append(j+1)
		elif a[j] == 1:
			if count_01 == 0:
				ans.append(j+1)
if not ans:
	print(0)
else:
	print(str(len(ans))+"\n" + " ".join(list(map(str,ans))))

Submission status: Runtime Error

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

s = [i for i, b in enumerate(a) if b]
print(len(s))
print(*s)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

def sol(i,want):
    num=int(N/(i+1))
    wa=-A[0]
    for j in range(num):
        wa+=A[i+j*i]
    wa=wa%2
    if wa==want:
        x=0
    else:
        x=1
#     print(num)
    return x 

B=A[:]
for i in range(half):
    j=half-1-i
#     print(j)
    B[j]=sol(j,A[j])
    
C=[]
for b in B:
    if b==1:
        C.append(b)
m=sum(B)
print(m)
for i in range(m):
    print(C[i])

Submission status: Runtime Error

Solution code:
N = int(input())
a = list(map(int, input().split()))
 
ball = [0] * N
 
 
if a[-1] == 1:
        ball[-1] = 1
 
for i in reversed(range(N-1)):
        tmp = 0
        if i != 0:
                for j in range(i + (i + 1), N, i + 1):
                        #print("i j ", i , j)
                        if (j + 1) % (i + 1) == 0:
                                tmp += ball[j]
        else:
                tmp = ball[1:]
        #print(i+1, tmp, a[i])
        if tmp % 2 != a[i]:
                ball[i] = 1
 
#print(ball)
 
print(sum(ball))
for i in range(N):
        if ball[i] == 1:
                print(i+1, end = " ")

Submission status: Runtime Error

Solution code:
def get_divisor(n):
    if n==1:return [1]
    for i in range(1,int(n**0.5)+1):
        if n%i==0:
            a.append(i)
            b.append(n//i)
    if a[-1]==b[-1]:b.pop()
    a.extend(b[::-1])
    return a

N = int(input())
*A, = map(int,input().split())
D = [0]*(N+1)
ans = []
for i in range(N,0,-1):
    if D[i]%2 != A[i-1]:
        ans.append(i)
        for j in get_divisor(i):
            D[j]+=1
print(len(ans))
print(*ans)

Submission status: Runtime Error

Solution code:
N = int(input())
a = list(map(int, input().split()))
 
ball = [0] * N
 
 
if a[-1] == 1:
        ball[-1] = 1
 
for i in reversed(range(N-1)):
        tmp = 0
        if i != 0:
                for j in range(i + (i + 1), N, i + 1):
                        #print("i j ", i , j)
                        if (j + 1) % (i + 1) == 0:
                                tmp += ball[j]
        else:
                tmp = ball(a[1:])
        #print(i+1, tmp, a[i])
        if tmp % 2 != a[i]:
                ball[i] = 1
 
#print(ball)
 
print(sum(ball))
for i in range(N):
        if ball[i] == 1:
                print(i+1, end = " ")

Submission status: Runtime Error

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

def sol(i,want):
    num=int(N/(i+1))
    wa=-A[0]
    for j in range(num):
        wa+=A[i+j*i]
    wa=wa%2
    if wa==want:
        x=0
    else:
        x=1
#     print(num)
    return x 

B=A[:]
for i in range(half):
    j=half-1-i
#     print(j)
    B[j]=sol(j,A[j])
m=sum(B)
print(m)
ans=''
for b in B:
    ans+=str(b)+ ' '
print(ans)

Submission status: Runtime Error

Solution code:
N=int(input())
A=list(map(int,input().split()))
ans = []
for i in reversed(range(1, N+1)):
    a = A[i-1]
    for j in range(2, N+1):
        tmp = i * j
        if tmp > N:
            break
        a %= A[tmp-1]
    if a % 2 == 1:
        ans.append(i)
    A[i-1] = a % 2
print(len(ans))
for a in ans:
    print(a)

Submission status: Runtime Error

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


for i in range((n//2+1),n+1):
  b[i]=a[i]
for i in range(n//2,0,-1):

  j=2
  b[i]=a[i]
  while(j*i=<n):
    b[i]^=a[j*i]
    j+=1

m=0
for i in range(n):
  m+=b[i]
print(m)
print(b)
for i in range(n):
  if b[i]==1:
    print(i)

Submission status: Runtime Error

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

ball = [0] * N

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

print(*ball)

Submission status: Runtime Error

Solution code:
import math
def func1(lst, value):
    return [i+1 for i, x in enumerate(lst) if x == value]
N = int(input())
a = list(map(int,input().split()))

b = [0] * N
half = math.ceil(N/2)
summ = 0
for i in reversed(range(N)):
    # print(i)
    if i >= half-1:
        b[i] = a[i]
    else:
    x = N//(i+1)
    # print("x",x)
        if x == 1:
            b[i] = a[i]
        else:
            for j in range(x):
                # print(j)
                summ += a[(i+1)*(j+1)-1]
            summ -= a[i]
            # print("sum=",summ)
            judge=summ%2
            # print("judge",judge)
            if (judge==0 and a[i]==0) or (judge==1 and a[i]==1):
                b[i] = 0
            else:
                b[i] = 1
            summ = 0
            judge = 0
# print(b)
print(sum(b))
if sum(b) != 0:
    ans = func1(b,1)
    # print(ans)
    if len(ans)>1:
        ans = map(str,ans)
        print(" ".join(ans))
    else:
        print(ans.pop())

Submission status: Runtime Error

Solution code:
N = int(input())
arr = map(int, input().split(' '))
ans = [0 for x in range(N)]
for i in reversed(range(N)):
  n = i + 1
  s = 0
  for k in reversed(range(1, N // n)):
	index = n*(k+1) - 1
	s += arr[index]
  if s % 2 == arr[i]:
     ans[i] = 0
  else:
     ans[i] = 1
    	
ans_arr = []
for i in ans:
  if i == 1:
    ans_arr.append(i)

print(sum(ans))
print(' '.join(ans_arr))

Submission status: Runtime Error

Solution code:
N = int(input())
arr = map(int, input().split(' '))
ans = [0 for x in range(N)]
for i in reversed(range(N)):
  n = i + 1
  s = 0
  for k in reversed(range(1, N // n)):
	index = n*k - 1
	s += arr[index]
  if s % 2 == arr[i]:
     ans[i] = 0
  else:
     ans[i] = 1
    	
ans_arr = []
for i in ans:
  if i == 1:
    ans_arr.append(i)

print(sum(ans))
print(' '.join(ans_arr))

Submission status: Runtime Error

Solution code:
N = int(input())
arr = map(int, input().split(' '))
ans = [0 for x in range(N)]
for i in reversed(range(N)):
  n = i + 1
  if n > N/2.0:
    ans[i] == arr[i]:
  else:
    s = 0
  	for k in reversed(range(1, N // n)):
    	index = n*k - 1
        s += arr[index]
    if s % 2 == arr[i]:
      ans[i] = 0
    else:
      ans[i] = 1
    	
ans_arr = []
for i in ans:
  if i == 1:
    ans_arr.append(i)

print(sum(ans))
print(' '.join(ans_arr))

Submission status: Runtime Error

Solution code:
N = int(input())
arr = map(int, input().split(' '))
ans = [0 for x in range(N)]
for i in reversed(range(N)):
  n = i + 1
  if n > N/2.0:
    ans[i] == arr[i]:
  else:
    s = 0
  	for k in reversed(range(1, N // n)):
    	index = n*k - 1
        s += arr[index]
    if s % 2 == arr[i]:
      ans[i] = 0
    else:
      ans[i] = 1
    	
ans_arr = []
for i in ans:
  if ans == 1:
    ans_arr.append(i)

print(sum(ans))
print(' '.join(ans_arr))