Problem:


Score : 400 points

Problem Statement

There are N empty boxes arranged in a row from left to right.
The integer i is written on the i-th box from the left (1 \leq i \leq N).

For each of these boxes, Snuke can choose either to put a ball in it or to put nothing in it.

We say a set of choices to put a ball or not in the boxes is good when the following condition is satisfied:

For every integer i between 1 and N (inclusive), the total number of balls contained in the boxes with multiples of i written on them is congruent to a_i modulo 2.

Does there exist a good set of choices? If the answer is yes, find one good set of choices.

Constraints

All values in input are integers.

1 \leq N \leq 2 \times 10^5

a_i is 0 or 1.

Input

Input is given from Standard Input in the following format:

N
a_1 a_2 ... a_N

Output

If a good set of choices does not exist, print -1.

If a good set of choices exists, print one such set of choices in the following format:

M
b_1 b_2 ... b_M

where M denotes the number of boxes that will contain a ball, and b_1,\ b_2,\ ...,\ b_M are the integers written on these boxes, in any order.

Sample Input 1

3
1 0 0

Sample Output 1

1
1

Consider putting a ball only in the box with 1 written on it.

There are three boxes with multiples of 1 written on them: the boxes with 1, 2, and 3. The total number of balls contained in these boxes is 1.

There is only one box with a multiple of 2 written on it: the box with 2. The total number of balls contained in these boxes is 0.

There is only one box with a multiple of 3 written on it: the box with 3. The total number of balls contained in these boxes is 0.

Thus, the condition is satisfied, so this set of choices is good.

Sample Input 2

5
0 0 0 0 0

Sample Output 2

0

Putting nothing in the boxes can be a good set of choices.



Sample input:
3
1 0 0


Sample output:
1
1

Submission status: Wrong Answer

Solution code:
import numpy as np
N = int(input())
A = [int(x) for x in input().split()]
solls = np.zeros(N+1)
A.insert(0,0)
solls[N//2+1:] = A[N//2+1:]

for i in range(N//2,0,-1):
    s = 0
    for j in range(2*i,N+1,i):
        s = s+A[j]
    if s%2 == 0 and A[i] == 1:
        solls[i] = 1
    if s%2 == 1 and A[i] == 0:
        solls[i] = 1

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

print(s)
print(*ls)

Submission status: Wrong Answer

Solution code:
import sys
from bisect import *
from collections import *
from copy import deepcopy
from heapq import *
from itertools import *
from math import *
from operator import *
import numpy as np

sys.setrecursionlimit(10**8)

input = sys.stdin.readline

def main():
    """ main """
    N = int(input())
    AS = list(map(int, input().split()))

    res = [0]*N
    for i in range(1,N+1)[::-1]:
        a = AS[i-1]
        if N//2 < i and a == 1:
            res[i-1] = 1
        elif i <= N//2:
            if (sum([AS[j-1] for j in range(i*2,N+1,i)])-a) % 2 == 1:
                res[i-1] = 1
    print(res.count(1))
    if res.count(1) != 0:
        print(*[i+1 for i,r in enumerate(res) if r == 1])

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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):
            break
        else:
            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: Wrong Answer

Solution code:
N = int(input())
a = [0] + list(map(int, input().split()))
b = [0] * (N + 1)
c = []
for i in range(N, 0, -1):
    sum_i = 0
    for j in range(i+i, N, i):
        sum_i += b[j]
    b[i] = (a[i] + sum_i)%2
print(sum(b))
for k in range(N):
    if b[k] == 1:
        c.append(b[k])
if c != []:
    print(' '.join(map(str, c)))

Submission status: Wrong Answer

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

for i in range(N):
    if b[i] == 1:
        c.append(b[i])
if c != []:
    print(' '.join(map(str, c)))

Submission status: Wrong Answer

Solution code:
N = int(input())
a = [0] + list(map(int, input().split()))
b = [0] * (N + 1)
for i in range(N, N//2, -1):
    b[i] = a[i]
for i in range(N//2, 0, -1):
    sum = 0
    for j in range(i+i, N, i):
        sum += b[j]
    b[i] = (a[i] + sum)%2
b.pop(0)
b = list(map(str, b))
print(' '.join(b))

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [int(x) for x in input().split()]
B = [0] * N
C = []
for i in range(N,0,-1):
  parity = 0
  j = 2
  while(i * j <= N):
    parity += B[i * j - 1]
    j += 1
  B[i - 1] = (A[i - 1] - parity) % 2
print(sum(B))
for i in range(N):
  if(B[i] == 1):
    C.append(str(i))
if(C != []):
  print(" ".join(C))

Submission status: Wrong Answer

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-1)*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: Wrong Answer

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]
    j = 2
    while (N-i)*j <= N:
        if (N-1)*j in c:
            count += 1
        j = 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: Wrong Answer

Solution code:
n=int(input())
A=[0]+list(map(int, input().split()))
B=[0]*(n+1)
B[n//2+1:]=A[n//2+1:]
for i in range(n//2, 0, -1):
  B[i]=(sum([B[j] for j in range(2*i, n+1, i)])+A[i])&1
res=[]
for i in range(n):
  if B[i]==1:
    res.append(i)
print(len(res))
if res:
  print(" ".join([str(e) for e in res]))

Submission status: Wrong Answer

Solution code:
n=int(input())
A=[0]+list(map(int, input().split()))
B=[0]*(n+1)
for i in range(n, 0, -1):
  if sum([B[j] for j in range(i, n+1, i)])&1!=A[i]:
    B[i]+=1
res=[]
for i in range(n):
  if B[i]==1:
    res.append(i)
print(len(res))
if res:
  print(" ".join([str(e) for e in res]))

Submission status: Wrong Answer

Solution code:
n=int(input())
A=list(map(int, input().split()))
A.insert(0, 0)
B=[0]*(n+1)
for i in range(n, 0, -1):
  if sum([B[j] for j in range(i, n+1, i)])&1!=A[i]:
    B[i]=1
res=[]
for i in range(n):
  if B[i]==1:
    res.append(i)
print(len(res))
if res:
  print(" ".join([str(e) for e in res]))

Submission status: Wrong Answer

Solution code:
n=int(input())
A=list(map(int, input().split()))
A.insert(0, 0)
B=[0]*(n+1)
for i in range(n//2, 0, -1):
  if sum([B[j] for j in range(i, n+1, i)])&1!=A[i]:
    B[i]=1
res=[]
for i in range(n):
  if B[i]==1:
    res.append(i)
print(len(res))
if res:
  print(" ".join([str(e) for e in res]))

Submission status: Wrong Answer

Solution code:
n=int(input())
A=list(map(int, input().split()))
A.insert(0, 0)
B=[0]*(n+1)
B[n//2+1:]=A[n//2+1:]
for i in range(n//2, 0, -1):
  if sum([B[j] for j in range(i, n+1, i)])&1!=A[i]:
    B[i]=1
res=[]
for i in range(n):
  if B[i]==1:
    res.append(i)
print(len(res))
if res:
  print(" ".join([str(e) for e in res]))

Submission status: Wrong Answer

Solution code:
n=int(input())
A=list(map(int, input().split()))
A.insert(0, 0)
B=[0]*(n+1)
B[n//2+1:]=A[n//2+1:]
for i in range(n//2, 0, -1):
  B[i]=A[i]
  k=2
  while i*k<=n:
    B[i]^=A[i*k]
    k+=1
res=[]
for i in range(n):
  if B[i]==1:
    res.append(i)
if not res:
  print(0)
else:
  print(len(res))
  print(" ".join([str(e) for e in res]))

Submission status: Wrong Answer

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

final_list = [0 for _ in range(N)]
ans_list = []
for n in reversed(range(N)):
    i = n+1
    quot = N // i
    rem = S[n]
    count = 0
    for j in range(1, quot+1):
        tmp_a = final_list[i*j -1]
        count ^= tmp_a
    if rem != count:
        final_list[n] = 1 
        ans_list.append(i)
        
print(len(ans_list))
print(''.join(map(str, ans_list)))

Submission status: Wrong Answer

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

for i in range(1,n + 1)[::-1]:
    j = 2
    while (i*j <= n):
        b_arr[i] += b_arr[i*j]
        b_arr[i] %= 2
        j += 1

m = sum(b_arr)
print(m)
if m:
    for i in b_arr:
        if i:
            print(i)

Submission status: Wrong Answer

Solution code:
from functools import reduce
add = lambda a, b: a+b

N = int(input())
a = [0] + [int(x) for x in input().split()]
balls = [0]*(N+1)
num = 0
for i in range(N, 0, -1):
  # print([balls[j] for j in range(i, N+1, i)])
  summ = reduce(add, [balls[j] for j in range(i, N+1, i)])
  if summ % 2 == a[i]:
    pass
  else:
    num += 1
    balls[i] += 1

print(num)
if num != 0:
  print(" ".join(["1" for _ in range(num)]))

Submission status: Wrong Answer

Solution code:
from functools import reduce
add = lambda a, b: a+b

N = int(input())
a = [0] + [int(x) for x in input().split()]
balls = [0]*(N+1)

for i in range(N, 0, -1):
  summ = reduce(add, [balls[j] for j in range(i, N+1, i)])
  if summ % 2 == a[i]:
    pass
  else:
    balls[i] += 1

ones = 0
for b in balls:
  if b == 1:
    ones += 1
print(ones)
if ones != 0:
  print(" ".join(["1" for _ in range(ones)]))

Submission status: Wrong Answer

Solution code:
from functools import reduce
add = lambda a, b: a+b

N = int(input())
a = [0] + [int(x) for x in input().split()]
balls = [0]*(N+1)

for i in range(N, 0, -1):
  summ = reduce(add, [balls[j] for j in range(i, N+1, i)])
  if summ % 2 == a[i]:
    pass
  else:
    balls[i] += 1

summ = reduce(add, balls)
print(summ)
if summ != 0:
  print(" ".join([str(x) for x in balls[1:]]))

Submission status: Wrong Answer

Solution code:

n=int(input())
l=list(map(int,input().split()))
ans =[0 for _ in range(n)]
count=0
for i in range(n-1,-1,-1):
    if sum([ans[j]for j in range(i,n,i+1)])!=l[i]:
        ans[i]=1
        count +=1

print(count)
[print(i+1,end=" ") for i,x in enumerate(ans) if x==1]

Submission status: Wrong Answer

Solution code:
n = int(input())
li = 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

li.reverse()

li_len = len(li)

li_ans = []
dic = {}
for n, l in enumerate(li):
    i = li_len - n
    s = 0
    if dic.get(i):
        s = dic[i]
    d2 = s % 2
    if l == d2:
        li_ans.append(0)
    else:
        divi = make_divisors(i)
        for d in divi:
            dic.setdefault(d, 0)
            dic[d] += 1
        li_ans.append(1)

li_ans.reverse()
print(sum(li_ans))
print(' '.join(map(str, li_ans)))

Submission status: Wrong Answer

Solution code:
a=int(input())
b=list(map(int, input().split()))
cou=1
ans=[]
cou2=0
ans2=0
while cou<=a:
  i=1
  su=0
  while i*cou-1<a:
    su+=b[i*cou-1]
    i+=1
  if su%2==b[cou-1]:
    if b[cou-1]==1:
      ans+=[str(cou)]
      ans2+=1
      ans+=[" "]
  else:
      cou2=1
  cou+=1
if cou2==1:
  print(-1)
else:
  if ans==[]:
    print("0")
  else:
    s=""
    del ans[-1]
    for i in ans:
      s+=str(i)
    print(ans2)
    print(s)

Submission status: Wrong Answer

Solution code:
a=int(input())
b=list(map(int, input().split()))
cou=1
ans=[]
cou2=0
while cou<=a:
  i=1
  su=0
  while i*cou-1<a:
    su+=b[i*cou-1]
    i+=1
  if su%2==b[cou-1]:
    if b[cou-1]==1:
      ans+=[str(cou)]
      ans+=[" "]
  else:
      cou2=1
  cou+=1
if cou2==1:
  print(-1)
else:
  if ans==[]:
    print("0")
  else:
    s=""
    del ans[-1]
    for i in ans:
      s+=str(i)
    print(s)

Submission status: Wrong Answer

Solution code:
n = int(input())
# n = 4

# a = [0, 2, 3, 5]
a = list(map(int, input().split()))
box = [0]*n
for i in range(n,0,-1):
    sum_box = 0
    for j in range(i,n+1,i):
        sum_box+=box[j-1]
    if sum_box%2!=a[i-1]:
        box[i-1]+=1

if sum(box):
    ans = []
    for i, x in enumerate(box):
        if x:
            ans.append(i+1)
    print(*ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
# n = 4
# a = [0, 2, 3, 5]
a = list(map(int, input().split()))

box = [0]*n
for i in range(n,0,-1):
	sum_box = 0
	for j in range(i,n+1,i):
		sum_box+=box[j-1]
	if sum_box%2!=a[i-1]:
		box[i-1]+=1

if sum(box):
	ans = []
	for i, x in enumerate(box):
		if x:
			ans.append(i+1)
	print(*ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
# n = 4
# a = [0, 2, 3, 5]
a = list(map(int, input().split()))

box = [0]*n
for i in range(n,0,-1):
	sum_box = 0
	for j in range(i,n+1,i):
		sum_box+=box[j-1]
		if sum_box%2!=a[i-1]:
			box[i-1]+=1
	print(sum(box))

if sum(box):
	ans = []
	for i, x in enumerate(box):
		if x:
			ans.append(i+1)
	print(*ans)

Submission status: Wrong Answer

Solution code:
a=int(input())
b=list(map(int, input().split()))
cou,ju=0,0
ans=[]
while cou<a:
  i=1
  su=0
  while i*(cou+1)<a:
    su+=b[i*(cou+1)]
    i+=1
  if su%2!=b[cou]:
    ans+=[str(cou+1)]
    ans+=[" "]
  cou+=1
if ans==[]:
  print("0")
else:
  s=""
  del ans[-1]
  for i in ans:
    s+=str(i)
  print(s)

Submission status: Wrong Answer

Solution code:
a=int(input())
b=list(map(int, input().split()))
cou,ju=0,0
ans=[]
while cou<a:
  i=1
  su=0
  while i*(cou+1)<a:
    su+=b[i*(cou+1)]
    i+=1
  if su%2!=b[cou]:
    ans+=[cou+1]
  cou+=1
if ans==[]:
  print("0")
else:
  s=""
  for i in ans:
    s+=str(i)+" "
  print(s)

Submission status: Wrong Answer

Solution code:
import sys
import math
from copy import deepcopy
from collections import deque
sys.setrecursionlimit(20000000)


def main():
    N = int(input())
    boxes = [0] * (N+1)
    ans_boxes = [0]
    [ans_boxes.append(x) for x in list(map(int, input().split()))]

    count = 0
    ans = []

    def judge(n):
        s = 0

        nn = n
        while nn < len(boxes):
            s += boxes[n]
            nn += n

        if s % 2 == ans_boxes[i]:
            return True
        else:
            return False

    for i in reversed(range(1, len(boxes))):
        if judge(i):
            continue

        else:
            count += 1
            ans.append(i)
            boxes[i] += 1
            if judge(i):
                pass
            else:
                print(-1)
                sys.exit()

    print(count)
    if ans:
        print(*ans, sep=' ')


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n = int(input())
# n = 5

arr = list(map(int, input().split()))
suffix_arr = [0]*(n+1)

conditional_flag = True

for i in range(1, n+1):
	for j in range(i, n+1, i):
		suffix_arr[i] += arr[j-1]
	if suffix_arr[i]%2 != arr[i-1]%2:
		conditional_flag = False
		break

if conditional_flag:
	b = [i+1 for i in range(i) if arr[i]]
	length = len(b)
	print(length)
	if length: print(*b)
else:
	print(-1)

Submission status: Wrong Answer

Solution code:
n=int(input())
listA=(input().split())
list1=[0 for i in range(n)]
list2=[]
numOfBox=0
s=0#考えるべきボールの数の合計
for i in range(n,0,-1):#n,n-1,...1って感じです
    #print(i)
    count=1
    while i*count<=n:
        s+=list1[i*count-1]
        count+=1
    #print(s)
    if s%2!=int(listA[i-1]):
        list1[i-1]+=1
        numOfBox+=1
        list2.append(i)
#print(list1)
print(numOfBox)
for i in range(len(list2)):
    print(list2[i],end=" ")

Submission status: Wrong Answer

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

b = [0]*(N+1)
for i in range(N,0,-1):
    if N//i == 1:
        b[i] = a[i]
    else:
        tmp = a[i]
        loop = N//i
        index = i*loop
        for j in range(loop):
            if j == loop-1: # end
                b[i] = tmp
            else:
                tmp = (tmp+b[index])%2
                index -= i
for e in b[1:]:
    print(e, end=" ")

Submission status: Wrong Answer

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

if cnt!=0:
    print(cnt)
    print(*ans)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n = ni()
arr = na()
s = sum(arr)
res = [0] * (n + 1)

for i in range(1, n + 1)[::-1]:
    sum_res = sum(res[x] for x in range(i, n + 1, i))
    res[i] = sum_res ^ arr[i - 1]

print(sum(res))

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

Submission status: Wrong Answer

Solution code:

n = int(input())
arr = [int(x) for x in input().split()]
balls = {}
result = []
reslen = 0

for i in range(n, n // 2, -1):
  if arr[i - 1] == 1:
    balls[i - 1] = 1
    result.append(str(i))
    reslen += 1
  else:
    balls[i - 1] = 0

for i in range(n // 2, 0, -1):
  s = sum([balls[i * m - 1] for m in range(2, n // i + 1)])
  if arr[i - 1] == 1:
    if (s % 2) == 1:
      balls[i - 1] = 0
    else:
      balls[i - 1] = 1
      result.append(str(i))
      reslen += 1
  if arr[i - 1] == 0:
    if (s % 2) == 0:
      balls[i - 1] = 0
    else:
      balls[i - 1] = 1
      result.append(str(i))
      reslen += 1

print(balls)
print('---')
print(reslen)
if reslen != 0:
  print(' '.join(result))

Submission status: Wrong Answer

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

lst = [0 for _ in range(n)]
for x in range(n) :
    if a[x] == 1 :
        for i in range(x//2) :
            if x%(i+1) == 0 :
                lst[i] ^= 1
        lst[x] ^= 1

b = 0
print(sum(lst))
print(*[i for i, x in enumerate(lst, 1) if x])

Submission status: Wrong Answer

Solution code:
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N=I()
    A=LI()
    B = [(i,a) for i,a in enumerate(A,start = 1)]

    #sigma(1/i) = O(log N)
    balls = set()
    for i,a in B:
        n = i
        cnt = 0
        for j in range(N):
            k = n*j
            if k > N:
                break
            elif k in balls:
                cnt += 1
        if cnt%2 != a:
            balls.add(i)
    print(len(balls))
    print(*balls,sep="\n")

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N=I()
    A=LI()
    B = [(i,a) for i,a in enumerate(A,start = 1)]

    #sigma(1/i) = O(log N)
    balls = set()
    for i,a in B:
        n = i
        cnt = 0
        for j in range(N):
            k = n*j
            if k > N:
                break
            elif k in balls:
                cnt += 1
        if cnt != a:
            balls.add(i)
    print(len(balls))
    print(*balls,sep="\n")

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

b = []

for i in range(N):
    ind = N-i
    val = 0
    j=2
    while ind*j<=N:
        val += a[ind*j-1]
        j+=1
    if val%2 != a[ind-1]:
        b.append(ind)
print(len(b))
if len(b)!=0:
    print(' '.join([str(b[len(b)-i-1]) for i in range(len(b))]))

Submission status: Wrong Answer

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

info = [0] * (n+1)

for i in range(0,n):
    count = 0
    for j in range(2,n//(n-i) + 1):
        count += info[(n-i)*j]
    if count != a[n-i]:
        info[n-i] = 1

ans = []

for k in range(1,n+1):
    if info[k] == 1:
        ans.append(k)

print(len(ans))
print(" ".join(map(str,ans)))

Submission status: Wrong Answer

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

info = [0] * (n+1)

for i in range(0,n):
    count = 0
    for j in range(2,n//(n-i) + 1):
        count += info[(n-i)*j]
    if count != a[n-i]:
        info[n-i] = 1

ans = []

for k in range(1,n+1):
    if info[k] == 1:
        ans.append(k)

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

Submission status: Wrong Answer

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

bs = nums.copy()
res = []

for i in range(n // 2, 0, -1):
    val = 0
    for j in range(1, n // i):
        val += bs[i * j - 1]
    bs[i - 1] = val % 2
for i in range(n):
    if bs[i] > 0:
        res.append(i + 1)
m = sum(bs)
print(m)
if m > 0:
    print(' '.join(map(str, res)))

Submission status: Wrong Answer

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

bs = nums.copy()
res = []

for i in range(n // 2, 0, -1):
    bs[i] = 0
    for j in range(1, n // i):
        bs[i] += bs[i * j]
    bs[i] %= 2
for i in range(n):
    if bs[i] > 0:
        res.append(i + 1)
m = sum(bs)
print(m)
if m > 0:
    print(' '.join(map(str, res)))

Submission status: Wrong Answer

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

for i in reversed(range(0,n)):
    cnt=0
    for j in range(i+1,n+1,i+1):
        if j==i:
            continue
        else:
            if flags[j-1]==1:
                cnt+=1
    if (a[i]+cnt)%2==0:
        flags[i]=0
    else:
        flags[i]=1
        ans.append(i+1)

if len(ans)==0:
    print(-1)
else:
    print(len(ans))
    for i in ans:
        print(i)

Submission status: Wrong Answer

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

for i in reversed(range(0,n)):
    l=b[n-1:]
    if a[i] == sum(l[j-1] for j in range(0,len(l),n))%2:
        b[i]=0
    else:
        b[i]=1
        flags.append(i+1)



if sum(b)%2!=a[0]:
    print(-1)
else:
    print(len(flags))
    for i in flags:
        print(i)

Submission status: Wrong Answer

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

if cnt!=0:
    print(cnt)
    print(*ans)
else:
    print(0)

Submission status: Wrong Answer

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

for i in range(n,0,-1):
    ball=box[i]
    j=2
    while(i*j<=n):
        ball+=a[i*j]
        j+=1
    if ball%2!=a[i]:
        box[i]=1
        b.append(i)
        ans+=1

print(ans)
for bb in b:
    print(bb, end=" ")

Submission status: Wrong Answer

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

n = int(input())
a_lst = list(map(int, input().split()))
b_lst = [0]*n

def multiple_i(i, n):
        lst = []
        j = 2
        while(1):
            if i*j <= n:
                lst += [i*j]
                j += 1
            else:
                break
        return lst

for i in range(1, n+1):
    r = a_lst[-i]
    if not n+1-i >= n / 2:
        mul_lst = multiple_i(n+1-i, n)
        ball = 0
        for mul in mul_lst:
            if b_lst[mul - 1] == 1:
                ball += 1
        if not ball % 2 == r:
            b_lst[-i] = 1
    else:
        if r == 1:
            b_lst[-i] = 1

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

print(m)
for i in range(m):
    print(ans_lst[i], end=" ")

Submission status: Wrong Answer

Solution code:
n = int(input())
A = list(map(int, input().split()))
fixed = [-1]*n
idx = n-1
flg = True
ans = []
cnt = 0
for a in reversed(A):
  if sum(A[idx::idx+1]) % 2 == a:
    if a == 1:
      cnt += 1
      ans.append(idx+1)
  idx -= 1
if flg:
  print(cnt)
  print(*ans)
else:
  print('-1')

Submission status: Wrong Answer

Solution code:
n = int(input())
A = list(map(int, input().split()))
fixed = [-1]*n
idx = n-1
flg = True
ans = []
cnt = 0
for a in reversed(A):
  if sum(A[idx::idx+1]) % 2 == a:
    if a == 1:
      cnt += 1
      ans.append(idx+1)
  else:
    flg = False
    break
  idx -= 1
if flg:
  print(cnt)
  print(*ans)
else:
  print(-1)

Submission status: Wrong Answer

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

def factorization(n):
    arr = set()
    temp = n
    
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.add(cnt)
            arr.add(i)

    if temp!=1:
        arr.add(temp)
        arr.add(1)

    if arr==():
        arr.add(n)
        arr.add(1)

    return arr

# Nの倍数の数を格納する辞書
baisuu = {i:0 for i in range(1,N+1)}
M=0
out_list=[]

a=listA

half=N//2

for i,ai in enumerate(a):
    now_index=N-i
    if now_index > half:
        if ai==1:
            soinsuu = factorization(now_index)
            out_list.append(now_index)
            M+=1
            for so in soinsuu:
                baisuu[so]+=1
    else:
        if baisuu[now_index]%2!=int(ai):
            out_list.append(now_index)
            M+=1
            soinsuu = factorization(now_index)
            for so in soinsuu:
                baisuu[so]+=1

print(M)
if M>0:
    out_list=sorted(out_list)
    print(" ".join(list(map(str, out_list))))

Submission status: Wrong Answer

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

def factorization(n):
    arr = set()
    temp = n
    
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.add(cnt)
            arr.add(i)

    if temp!=1:
        arr.add(temp)
        arr.add(1)

    if arr==():
        arr.add(n)
        arr.add(1)

    return arr

# Nの倍数の数を格納する辞書
baisuu = {i:0 for i in range(1,N+1)}
M=0
out_list=[]

a=listA

half=N//2

for i,ai in enumerate(a):
    now_index=N-i
    if now_index > half:
        if ai==1:
            soinsuu = factorization(now_index)
            print(soinsuu,now_index)
            out_list.append(now_index)
            M+=1
            for so in soinsuu:
                baisuu[so]+=1
    else:
        if baisuu[now_index]%2!=int(ai):
            out_list.append(now_index)
            M+=1
            soinsuu = factorization(now_index)
            for so in soinsuu:
                baisuu[so]+=1

print(M)
if M>0:
    out_list=sorted(out_list)
    print(" ".join(list(map(str, out_list))))

Submission status: Wrong Answer

Solution code:
def main():
    import sys
    input = sys.stdin.readline
    
    N = int(input())
    A = list(map(int, input().split()))
    count = [0]*N
    answer=[]
    M = 0
    for i in range(N)[::-1]:
        print(i)
        j = i+1
        if count[i]%2 != A[i]:
            answer.append(j)
            M += 1
            div = make_divisors(j)
            for k in div:
                count[k-1] += 1
    print(M)
    print(*answer)

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

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    import sys
    input = sys.stdin.readline
    
    N = int(input())
    A = list(map(int, input().split()))
    count = [0]*N
    answer=[]
    M = 0
    for i in range(N)[::-1]:
        j = i+1
        if count[i]//2 != A[i]:
            answer.append(j)
            M += 1
            div = make_divisors(j)
            for k in div:
                count[k-1] += 1
    print(M)
    print(*answer)

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

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
import copy

#任意の数の倍数リストを作成する
def make_multiple(N,target):
	multiple_list = list()
	for i in range(1,N+1): #この書き方って0も入るじゃない??
		if i % target == 0:
			multiple_list.append(i)
			break
	return multiple_list



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

#全て0の時はそのまま0を表示して終了
a_c = copy.deepcopy(a)
a_s =set(a_c)
a_c = list(a_s)
if len(a_c) == 1 and a_c[0] == 0:
	print(0)
	sys.exit()

a.insert(0,0) #便宜上一番最初に0をinsert、最後にpopする

for i in range(len(a)):
	target_list = list()
	if a[i] != 0:
		# print('a[',i,']:',a[i])
		target_list =make_multiple(N,a[i])
		# if len(target_list) 
		# print(target_list,':',len(target_list))
		# print(len(target_list),'%',2,'=',len(target_list)%2)
		print(1)
		print(target_list[0])