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 sys


def IN_I(): return int(sys.stdin.readline().rstrip())
def IN_LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def IN_S(): return sys.stdin.readline().rstrip()
def IN_LS(): return list(sys.stdin.readline().rstrip().split())


N = IN_I()
a = [0] + IN_LI()
b = [0] * (N + 1)
ans = []

for i in range(N, 0, -1):
    tmp = 0
    for j in range(2 * i, N + 1, i):
        tmp += b[j]
    if tmp % 2 != a[i]:
        b[i] = 1
        ans.append(i)
if len(ans) == 0:
    print(0)
else:
    print(' '.join(map(str, ans)))

Submission status: Wrong Answer

Solution code:
import sys


def IN_I(): return int(sys.stdin.readline().rstrip())
def IN_LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def IN_S(): return sys.stdin.readline().rstrip()
def IN_LS(): return list(sys.stdin.readline().rstrip().split())


N = IN_I()
a = IN_LI()
b = [0] * N

for i in range(N - 1, -1, -1):
    if a[i] == 1:
        b[i] = 1 - b[i]
        if (i + 1) % 2 == 0:
            b[i // 2] = 1
ans = []
for i in range(N):
    if b[i] == 1:
        ans.append(i + 1)

if len(ans) == 0:
    print(0)
else:
    print(' '.join(map(str, ans)))

Submission status: Wrong Answer

Solution code:
def factorize(n):
    a=[1]
    while n%2==0:
        a.append(2)
        n//=2
    f=3
    while f*f<=n:
        if n%f==0:
            a.append(f)
            n//=f
        else:
            f+=2
    if n!=1:
        a.append(n)
    return list(set(a))
n=int(input())
table=[0]*(n+1)
ball=[]
a=list(map(int,input().split()))[::-1]
for i in range(n):
    if table[n-i]!=a[i]:
        ball.append(n-i)
        for j in factorize(n-i):
            table[j]=1-table[j]
print(len(ball))
if len(ball)!=0:
    print(*ball)

Submission status: Wrong Answer

Solution code:
def factorize(n):
    a=[1]
    while n%2==0:
        a.append(2)
        n//=2
    f=3
    while f*f<=n:
        if n%f==0:
            a.append(f)
            n//=f
        else:
            f+=2
    if n!=1:
        a.append(n)
    return a
n=int(input())
table=[0]*(n+1)
ball=[]
a=list(map(int,input().split()))[::-1]
for i in range(n):
    if table[n-i]!=a[i]:
        ball.append(n-i)
        for j in factorize(n-i):
            table[j]=1-table[j]
print(len(ball))
if len(ball)==0:
    print(0)
else:
    print(*ball)

Submission status: Wrong Answer

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

ans=[]
b=[0]*n
for i in reversed(range(n)):
  if sum(b[i::i+1])%2!=a[i]:
    b[i]+=1
    ans.append(i)
        
print(sum(b))
print(*sorted(ans))

Submission status: Wrong Answer

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

m=0
ans=[]
c=[0]*(n+1)
for i in reversed(range(1,n+1)):
  if a[i]%2!=c[i]%2:
    m+=1
    ans.append(i)
    for j in range(1,int(i**0.5)+1):
      if i%j==0:
        c[j]+=1
        c[i//j]+=1
        c[j]%=2
        c[i//j]%=2

print(m)
print(*sorted(ans))

Submission status: Wrong Answer

Solution code:
N=int(input())
A=[0]+list(map(int,input().split()))
B=[0]
res=0
for n in range(1,N+1):
    a=n
    r=0
    while a<=N:
        r+=A[a]
        a+=n
    if r%2:
        res+=1
    B.append(r%2)
print(res)
print(*[i+1 for i in range(N) if B[i+1]>0],sep='\n')

Submission status: Wrong Answer

Solution code:

def main():
    n = int(input())
    a = [0]
    a.extend(list(map(int, input().split())))
    balls = [0]*(n+1)
    b = {}
    for i in range(n, 0, -1):
        ball = 0
        for j in range(i, n, i):
            ball += balls[j]
        if ball % 2 != a[i]:
            b[i] = 1
    if len(b) == 0:
        print(0)
        exit()
    else:
        print(len(b))
    ks = sorted(b.items(), key=lambda x:x[0])
    for k in ks:
        print(k[0], end=" ")


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:

url = "https://atcoder.jp//contests/abc134/tasks/abc134_d"

def main():
    n = int(input())
    a = [0]
    a.extend(list(map(int, input().split())))
    balls = [0]*(n+1)
    b = {}
    for i in range(n, 0, -1):
        ball = 0
        for j in range(i, n, i):
            ball += balls[j]
        if ball % 2 != a[i]:
            if ball % 2 >= 2:
                print(-1)
                exit()
            b[i] = 1
    if len(b) == 0:
        print(0)
        exit()
    else:
        print(len(b))
    ks = sorted(b.items(), key=lambda x:x[0])
    for k in ks:
        print(k[0], end=" ")


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:

url = "https://atcoder.jp//contests/abc134/tasks/abc134_d"

def main():
    n = int(input())
    a = [0]
    a.extend(list(map(int, input().split())))
    balls = [0]*(n+1)
    b = {}
    for i in range(n, 0, -1):
        ball = 0
        for j in range(i, n, i):
            ball += balls[j]
        if ball % 2 != a[i]:
            if ball % 2 >= 2:
                print(-1)
                exit()
            a[i] = 1
            b[i] = 1
    if len(b) == 0:
        print(0)
        exit()
    else:
        print(len(b))
    ks = sorted(b.items(), key=lambda x:x[0])
    for k in ks:
        print(k[0], end=" ")


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:

url = "https://atcoder.jp//contests/abc134/tasks/abc134_d"

def main():
    n = int(input())
    a = [0]
    a.extend(list(map(int, input().split())))
    balls = [0]*(n+1)
    b = {}
    for i in range(n, 0, -1):
        ball = 0
        for j in range(i, n, i):
            ball += balls[j]
        if ball % 2 != a[i]:
            if ball % 2 >= 2:
                print(-1)
                exit()
            a[i] = 1
            b[i] = 1
    if len(b) == 0:
        print(0)
        exit()
    else:
        print(len(b))
    ks = sorted(b.items(), key=lambda x:x[0])
    for k in ks:
        print(k, end=" ")


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:

url = "https://atcoder.jp//contests/abc134/tasks/abc134_d"

def main():
    n = int(input())
    a = [0]
    a.extend(list(map(int, input().split())))
    balls = [0]*(n+1)
    b = {}
    for i in range(n, 0, -1):
        ball = 0
        for j in range(i, n, i):
            ball += balls[j]
        if ball % 2 != a[i]:
            if ball % 2 >= 2:
                print(-1)
                exit()
            a[i] = 1
            b[i] = 1
    if len(b) == 0:
        print(0)
        exit()
    else:
        print(len(b))
    for k in b:
        print(k, end=" ")


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

print(sum(ans))
cnt = []
for i in range(len(ans)):
    if ans[i] == 1:
        cnt.append(i+1)
if sum(ans) > 0:
    print(*cnt)

Submission status: Wrong Answer

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

print(sum(ans))
cnt = []
for i in range(len(ans)):
    if ans[i] == 1:
        cnt.append(i+1)
if sum(ans) > 0:
    print(*cnt)

Submission status: Wrong Answer

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

print(sum(ans))
cnt = []
for i in range(len(ans)):
    if ans[i] == 1:
        cnt.append(i+1)
if sum(ans) > 0:
    print(*cnt)

Submission status: Wrong Answer

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

ans = [0 for i in range(N)]
for i in range(N-1,-1,-1):
    val = i+1
    if val*2>N:
        if A[i]==0:
            ans[i] = 0
        else:
            ans[i] = 1
    else:
        tmp = 0
        while(1):
            if val>N:
                break
            tmp += ans[val-1]
            val += val
        if A[i]==0:
            if tmp%2==0:
                ans[i]=0
            else:
                ans[i]=1
        else:
            if tmp%2==0:
                ans[i]=1
            else:
                ans[i]=0
cnt = 0
b=[]
for i in range(N):
    if ans[i]==0:
        continue
    cnt += 1
    b.append(i+1)

print(cnt)
print(*b)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

for i in range(N, 0, -1):
	tmpBalls = 0
	x = 1
	while i * x <= N:
		tmpBalls += balls[i*x]
		x += 1
	
	if A[i] == 1 and tmpBalls % 2 == 1:
		pass
		
	elif A[i] == 1 and tmpBalls % 2 == 0:
		balls[i] = 1
	
	elif A[i] == 0 and tmpBalls % 2 == 1:
		tmpBalls = 1
	
	elif A[i] == 0 and tmpBalls % 2 == 0:
		pass
		

isOkay = True
for i in range(1, N+1):
	if balls[i] > 1:
		print(-1)
		exit()
	
print(balls.count(1))	
for i in range(1, N+1):
	if balls[i]:
		print(i)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
b = [0] * n
ans = 0
for i in range(n)[::-1]:
    t = 0
    j = i+(i+1)
    while j <= n:
        t += b[j-1]
        j += (i+1)
    if a[i] == 0:
        if t % 2 == 0:
            b[i] = 0
        else:
            b[i] = 1
            ans += 1
    else:
        if t % 2 == 0:
            b[i] = 1
            ans += 1
        else:
            b[i] = 0
print(ans)
l = []
for i in range(n):
    if b[i] == 1:
        l.append(str(i+1))
print(' '.join(l))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
b = [0] * n
ans = 0
for i in range(n)[::-1]:
    t = 0
    j = i+(i+1)
    while j <= i:
        t += b[i]
    if a[i] == 0:
        if t % 2 == 0:
            b[i] = 0
        else:
            b[i] = 1
            ans += 1
    else:
        if t % 2 == 0:
            b[i] = 1
            ans += 1
        else:
            b[i] = 0
print(ans)
l = []
for i in range(n):
    if b[i] == 1:
        l.append(str(i+1))
print(' '.join(l))

Submission status: Wrong Answer

Solution code:
from collections import deque
N=int(input())
A=list(map(int,input().split()))
reverse_A=list(reversed(A))
numbers=[]
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]
boxes=[0 for _ in range(N)]
for n in range(N):
    yakusuu=make_divisors(n+1)
    numbers+=[yakusuu]
reverse_numbers=list(reversed(numbers))
answers=[0 for _ in range(N)]
balls=[0 for _ in range(N)]
for n in range(N-1):
    number=reverse_numbers[n]
    if balls[n]%2==0 and reverse_A[n]==1:
        answers[n]+=1
        for num in number:
            balls[num-1]+=1
    elif balls[n]%2==1 and reverse_A[n]==0:
        answers[n] += 1
        for num in number:
            balls[num - 1] += 1
if sum(answers)%2==0 and reverse_A[-1]==1:
    answers[-1]+=1
elif sum(answers)%2==1 and reverse_A[-1]==0:
    answers[-1]+=1
print(sum(answers))
reverse_answers = list(reversed(answers))
kotae = []
for n in range(N):
    if reverse_answers[n] != 0:
        kotae.append(n + 1)
print(*kotae)

Submission status: Wrong Answer

Solution code:
import math

def main():
	N = int(input())
	A = [int(a) for a in input().split(" ")]
	B = [0] * N
	for i in range(1, N):
		for j in range(math.ceil(N / (i + 1)), math.floor(N / i) + 1):
			ball = 0
			for k in range(2 * j, N + 1, j):
				ball += B[k - 1]
			B[j - 1] = (ball % 2 + A[j - 1]) % 2
	ans = [str(x + 1) for x, v in enumerate(B) if v == 1]
	print(len(ans))
	if len(ans) > 0:
		print(" ".join(ans))

main()

Submission status: Wrong Answer

Solution code:
import math

def main():
	N = int(input())
	A = [int(a) for a in input().split(" ")]
	B = [0] * N
	for i in range(1, N):
		for j in range(math.ceil(N / (i + 1)), math.floor(N / i) + 1):
			ball = 0
			for k in range(2 * j, N, j):
				if B[k - 1] == 1:
					ball += 1
			B[j - 1] = (ball % 2 + A[j - 1]) % 2
	ans = [str(x + 1) for x, v in enumerate(B) if v == 1]
	print(len(ans))
	if len(ans) > 0:
		print(" ".join(ans))

main()

Submission status: Wrong Answer

Solution code:
import math

def main():
	N = int(input())
	A = [int(a) for a in input().split(" ")]
	B = [0] * N
	for i in range(1, N):
		for j in range(math.ceil(N / (i + 1)), math.floor(N / i) + 1):
			ball = 0
			for k in range(2 * j, N, j):
				if B[k - 1] == 1:
					ball += 1
			B[j - 1] = (ball % 2 + A[j - 1]) % 2
	ans = [str(x + 1) for x, v in enumerate(B) if v == 1]
	print(len(ans))
	print(" ".join(ans))

main()

Submission status: Wrong Answer

Solution code:
import math

def main():
	N = int(input())
	A = [int(a) for a in input().split(" ")]
	B = [0] * N
	for i in range(1, N):
		for j in range(math.ceil(N / (i + 1)), math.floor(N / i) + 1):
			ball = 0
			for k in range(2 * j, N, j):
				if B[k - 1] == 1:
					ball += 1
			B[j - 1] = (ball % 2 + A[j - 1]) % 2
	ans = [str(x) for x, v in enumerate(B) if v == 1]
	print(" ".join(ans))

main()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
from collections import deque, defaultdict
from math import sqrt, factorial, gcd, ceil, atan, pi
def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline().strip() # warning bytes
# def input(): return sys.stdin.buffer.readline().decode('utf-8')
import string
# string.ascii_lowercase
from bisect import bisect_left, bisect_right
from functools import lru_cache
MOD = int(1e9)+7
INF = float('inf')


def solve():
    n = int(input())
    a = [int(x) for x in input().split()]
    xd = [0] * n
    ans = []
    for i in range(n-1,-1,-1):
        cnt = 0
        for j in range(i, n, i + 1):
            cnt += xd[j]
        cnt %= 2
        if cnt != a[i]:
            ans.append(i + 1)
    ans.reverse()
    print(len(ans))
    if ans:
        print(*ans)
        

    
t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()


"""
   1   2   3   4   5   6
1     [*] (0) [*] [*] (0) 
2 [*]     (1) [*] [*] (1) 
3 (0) (1)     (0) (1) (1) 
4 [*] [*] (0)     [*] (0) 
5 [*] [*] (1) [*]     (1) 
6 (0) (1) (1) (0) (1)     

1     (1) (0) (1) (1) (0) 
2 (1)     [*] (1) [*] [*] 
3 (0) [*]     (0) [*] [*] 
4 (1) (1) (0)     (1) (0) 
5 (1) [*] [*] (1)     [*] 
6 (0) [*] [*] (0) [*]     

"""

Submission status: Wrong Answer

Solution code:
def prime_list(n=10**6+1):
    res = []
    tmp = [1 for _ in range(n)]
    tmp[0] = 0
    tmp[1] = 0
    i = 2
    while i < len(tmp):
        j = i*2
        while tmp[i] == 1 and j < len(tmp):
            tmp[j] = 0
            j += i
        i += 1

    return tmp

n = int(input())
a = list(map(int, input().split()))
a = [0] + a
primes = prime_list(n+1)

new_a = [-1 for _ in range(n+1)]
new_a[1] = a[1]
for i in range(1, n+1):
    if primes[i]:
        new_a[i] = a[i]
        j = i
        while j <= n:
            if new_a[j] != -1 and (new_a[j] != a[i] or new_a[j] != a[j]):
                print(-1)
                exit()
            new_a[j] = a[i]
            j += i

cnt = 0
for i in range(1, n+1):
    if new_a[i] == 1:
        cnt += 1

print(cnt)

for i in range(1, n+1):
    if new_a[i] == 1:
        print(i, end=' ')

Submission status: Wrong Answer

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

r=""
c=0
for i in range(1,n+1):
  if ans[i]:
    c+=1
    r+=str(i)+" "
print(c)
print(r[:1])

Submission status: Wrong Answer

Solution code:
N = int(input())
ans = list(map(int,input().split()))
blist = [-1 for i in range(N)]
cnt = 0
one_list =[]
for i in reversed(range(N)):
    ssum =  0
    for j in range(1,N):
        ind = i * j - 1
        if(ind >= len(ans)):
            break
        else:
            if(blist[ind] == -1):
                pass
            else:
                ssum  += blist[ind]
    ssum %= 2
    to_put = ssum ^ ans[i]
    if(to_put == 1):
        cnt += 1
        one_list.append(i+1)
    blist[i] = to_put

print(cnt)
print(*one_list)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int,input().split()))
ans = [0 for i in range(N+1)]
flag = True
for i in range(N,0,-1):
    for j in range(1,N+1):
        if i*j>N:
            break
        else:
            if ans[i*j] %2 == a[i*j -1 ]%2:
                pass
            else:
                if j == 1:
                    ans[i*j] +=1
                else:
                    flag = False
                    break
if flag:
    print(sum(ans))
    print(*a[1:])

else:
    print(-1)

Submission status: Wrong Answer

Solution code:
N=int(input())
a=list(map(int,input().split()))
box=[0]*N
for i in range(N, 0,-1):
    sm = 0
    for j in range(i, N+1, i):
        sm += box[j-1]
    print(i, sm)
    box[i-1] = (sm % 2) ^ a[i-1]
print(sum(box))
print(*[i+1 for i in range(N) if box[i]])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
A = list(map(int,input().split()))
B = [0]*(n+1)
m = 0
for i in range(n,0,-1):
    cnt = 0
    for j in range(i,n,i):
        cnt += B[j]
    if cnt%2==A[i-1]:
        continue
    else:
        B[i] =1
        m += 1
print(m)
for i in range(len(B)):
    if B[i]==1:
        print(i)

Submission status: Wrong Answer

Solution code:
n = int(input())
box = [0 for _ in range(n)]
boxnum = [i for i in range(n)]
a = list(map(int,input().split()))
for i in range(1,n):
    tmp = sum(box[i::i]) % 2
    #print(boxnum[i::i])
    i -= 1
    if tmp == 0:
        if a[i] == 1:
            box[i] = 1
        else:
            box[i] = 0
    elif tmp == 1:
        if a[i] == 0:
            box[i] = 1
        else:
            box[i] = 0
if len([i for i in box if i > 0]):
    print(len([i for i in box if i > 0]))
    print(*[i for i in box if i > 0])
else:
    print(0)

Submission status: Wrong Answer

Solution code:
n = int(input())
box = [0 for _ in range(n)]
boxnum = [i for i in range(n)]
a = list(map(int,input().split()))
for i in range(n,1,-1):
    tmp = sum(box[i::i]) % 2
    #print(boxnum[i::i])
    i -= 1
    if tmp == 0:
        if a[i] == 1:
            box[i] = 1
        else:
            box[i] = 0
    elif tmp == 1:
        if a[i] == 0:
            box[i] = 1
        else:
            box[i] = 0
if len([i for i in box if i > 0]):
    print(len([i for i in box if i > 0]))
    print(*[i for i in box if i > 0])
else:
    print(0)

Submission status: Wrong Answer

Solution code:
n = int(input())
box = [0 for _ in range(n)]
boxnum = [i for i in range(n)]
a = list(map(int,input().split()))
for i in range(n,1,-1):
    tmp = sum(box[i::i]) % 2
    #print(boxnum[i::i])
    i -= 1
    if tmp == 0:
        if a[i] == 1:
            box[i] = 1
        else:
            box[i] = 0
    elif tmp == 1:
        if a[i] == 0:
            box[i] = 1
        else:
            box[i] = 0
if len([i for i in box if i > 0]):
    print(len([i for i in box if i > 0]))
    print(*box)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
n = int(input())
box = [0 for _ in range(n)]
boxnum = [i for i in range(n)]
a = list(map(int,input().split()))
for i in range(1,n):
    tmp = sum(box[i::i]) % 2
    #print(boxnum[i::i])
    i -= 1
    if tmp == 0:
        if a[i] == 1:
            box[i] = 1
        else:
            box[i] = 0
    elif tmp == 1:
        if a[i] == 0:
            box[i] = 1
        else:
            box[i] = 0
print(len([i for i in box if i > 0]))
print(*box)

Submission status: Wrong Answer

Solution code:
# 1からNまでの数字それぞれの約数を求める
# Nから(大きい値から)見ていき、1であれば入れる
# 数字iを入れた場合、iの約数の数を+1
# それぞれの数はdictで保持する

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

ans = [0 for _ in range(N)]

ans_num = 0
ans_list = ""
for i in range(N):
    tmp = N - i
    s = 0
    for j in range(tmp + 1, N + 1, tmp):
        if j % tmp == 0:
            s += ans[j-1]

    if s % 2 != A[tmp - 1]:
        ans[tmp - 1] = 1
        ans_num += 1
        ans_list += str(tmp)
        ans_list += " "


print(ans_num)
print(ans_list[:-1])

Submission status: Wrong Answer

Solution code:
# 1からNまでの数字それぞれの約数を求める
# Nから(大きい値から)見ていき、1であれば入れる
# 数字iを入れた場合、iの約数の数を+1
# それぞれの数はdictで保持する

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

ans = [0 for _ in range(N)]

ans_num = 0
for i in range(N):
    tmp = N - i
    s = 0
    for j in range(tmp, N, tmp):
        if (j+1) % tmp == 0:
            s += ans[j]

    if s % 2 != A[tmp - 1]:
        ans[tmp - 1] = 1
        ans_num += 1


print(ans_num)
ans_list = ""
for i in range(N):
    if ans[i] == 1:
        ans_list += str(i + 1)
        if i != N - 1:
            ans_list += " "

print(ans_list)

Submission status: Wrong Answer

Solution code:
# 1からNまでの数字それぞれの約数を求める
# Nから(大きい値から)見ていき、1であれば入れる
# 数字iを入れた場合、iの約数の数を+1
# それぞれの数はdictで保持する

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

table = [0 for _ in range(N)]
ans = [0 for _ in range(N)]

def divisor(n):
    i = 1
    while i * i <= n:
        if n%i == 0:
            table[i-1] += 1
            table[n//i - 1] += 1
        i += 1


for i in range(N):
    tmp = N - i
    if table[tmp - 1] % 2 != A[tmp - 1]:
        ans[tmp - 1] = 1
        divisor(tmp)


print(sum(ans))
ans_list = ""
for i in range(N):
    if ans[i] == 1:
        ans_list += str(i + 1)
        if i != N - 1:
            ans_list += " "

print(ans_list)

Submission status: Wrong Answer

Solution code:
# 1からNまでの数字それぞれの約数を求める
# Nから(大きい値から)見ていき、1であれば入れる
# 数字iを入れた場合、iの約数の数を+1
# それぞれの数はdictで保持する

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

def divisor(n):
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    table.sort()
    return table

dic = {}
ans = [0 for _ in range(N)]
for i in range(N):
    tmp = N - i
    if tmp in dic:
        if dic[tmp] % 2 != A[tmp-1]:
            dic[tmp] += 1
            ans[tmp - 1] = 1

    else:
        if A[tmp-1] == 1:
            dic[tmp] = 1
            ans[tmp - 1] = 1
        else:
            dic[tmp] = 0

print(sum(ans))
for i in range(N):
    if ans[i] == 1:
        print(i + 1)

Submission status: Wrong Answer

Solution code:
def resolve():
    '''
    code here
    '''
    N = int(input())
    As = [int(item) for item in input().split()]

    box = set()

    for i in range(N):
        num = N -i
        sum_num  = 0
        for j in range(num, N, num):
            if j in box:
                sum_num += 1

        if As[num-1] != sum_num % 2:
            box.add(num-1)

    print(len(box))

    for item in box:
        print(item +1)

if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

Solution code:
def resolve():
    '''
    code here
    '''
    N = int(input())
    As = [int(item) for item in input().split()]

    res = [0 for _ in range(N)]

    for i in range(N):
        num = N -i
        sum_num  = 0
        for j in range(num, N, num):
            sum_num += res[j-1]

        if As[num-1] != sum_num % 2:
            res[num-1] += 1

    ans_num = sum(res)
    print(ans_num)

    for i, item in enumerate(res):
        if item == 1:
            print(i+1)

if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

Solution code:
def resolve():
    '''
    code here
    '''
    N = int(input())
    As = [int(item) for item in input().split()]

    res = [0 for _ in range(N)]

    for i in range(N):
        num = N -i
        sum_num  = 0
        for j in range(num, N, num):
            sum_num += res[j-1]

        if As[num-1] != sum_num % 2:
            res[num-1] += 1
        print(num, As[num -1])
    ans_num = sum(res)
    print(ans_num)

    for i, item in enumerate(res):
        if item == 1:
            print(i+1, end=' ')

if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

Solution code:
def resolve():
    '''
    code here
    '''
    N = int(input())
    As = [int(item) for item in input().split()]

    res = [0 for _ in range(N)]

    for i in range(N):
        num = N -i
        
        sum_num  = 0
        for j in range(num, N, num):
            sum_num += res[j-1]

        if As[num-1] != sum_num % 2:
            res[num-1] += 1

    ans_num = sum(res)
    print(ans_num)
    for i, item in enumerate(res):
        if item:
            print(i+1)

if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

Solution code:
def resolve():
    '''
    code here
    '''
    N = int(input())
    As = [int(item) for item in input().split()]

    res = [0 for _ in range(N)]

    for i in range(N):
        num = N -i
        
        sum_num  = 0
        for j in range(num, N, num):
            sum_num += res[j-1]

        if As[num-1] != sum_num % 2:
            res[num-1] += 1

    ans_num = sum(res)
    print(ans_num)
    if ans_num != 0: 
        ans = []
        for i, item in enumerate(res):
            if item:
                print(i+1)
if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

Solution code:
def resolve():
    '''
    code here
    '''
    N = int(input())
    As = [int(item) for item in input().split()]

    res = [0 for _ in range(N)]

    for i in range(N):
        num = N -i
        
        sum_num  = 0
        for j in range(num, N, num):
            sum_num += res[j-1]

        if As[num-1] != sum_num % 2:
            res[num-1] += 1

    ans_num = sum(res)
    print(ans_num)
    if ans_num != 0: 
        ans = []
        for i, item in enumerate(res):
            if item:
                ans.append(i+1)
        print(*ans)

if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

Solution code:
def resolve():
    '''
    code here
    '''
    N = int(input())
    As = [int(item) for item in input().split()]

    res = [0 for _ in range(N)]

    for i in range(N):
        num = N -i
        
        sum_num  = 0
        for j in range(num, N, num):
            sum_num += res[j]

        if As[num-1] != sum_num % 2:
            res[num-1] += 1

    ans_num = sum(res)
    print(ans_num)
    if ans_num != 0: 
        ans = []
        for i, item in enumerate(res):
            if item:
                ans.append(i+1)
        print(*ans)

if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

Solution code:
def resolve():
    '''
    code here
    '''
    N = int(input())
    As = [int(item) for item in input().split()]

    res = [0 for _ in range(N)]

    for i in range(N):
        num = N -i
        
        sum_num  = 0
        for j in range(num, N, num):
            sum_num += res[j]

        if As[num-1] == 1:
            if sum_num % 2 == 0:
                res[num-1] += 1
        else:
            if sum_num % 2 == 1:
                res[num-1] += 1
    ans_num = sum(res)
    print(ans_num)
    if ans_num != 0: 
        ans = []
        for i, item in enumerate(res):
            if item:
                ans.append(i+1)
        print(*ans)

if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

Solution code:
def resolve():
    '''
    code here
    '''
    N = int(input())
    As = [int(item) for item in input().split()]

    res = [0 for _ in range(N)]

    for i in range(N):
        num = N -i
        
        sum_num  = 0
        for j in range(num, N, num):
            sum_num += res[j]

        if As[num-1] == 1:
            if sum_num % 2 == 0:
                res[num-1] += 1
        else:
            if sum_num % 2 == 1:
                res[num-1] += 1
    
    print(sum(res))
    ans = []
    for i, item in enumerate(res):
        if item:
            print(i+1)

if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

Solution code:
def resolve():
    '''
    code here
    '''
    N = int(input())
    As = [int(item) for item in input().split()]

    res = [0 for _ in range(N)]

    for i in range(N):
        num = N -i
        
        sum_num  = 0
        for j in range(num, N, num):
            sum_num += res[j]

        if As[num-1] == 1:
            if sum_num % 2 == 0:
                res[num-1] += 1
        else:
            if sum_num % 2 == 1:
                res[num-1] += 1
    
    print(sum(res))
    ans = []
    for item in res:
        if item:
            ans.append(item)
    print(*ans)
    
if __name__ == "__main__":
    resolve()