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

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

    divisors.sort()
    return divisors

cnt = 0
ans = [0] * (N+1)
digits = [0] * (N+1)
for i in range(N,0,-1):
    ans[i] = digits[i]%2 ^ A[i-1]
    cnt += ans[i]
    divs = make_divisors(i)
    for div in divs[:-1]:
        digits[div] += ans[i]
    
# print(digits)
# print(ans)
print(cnt)
for a in ans[1:]:
    if cnt <= 0:
        break
    print(a)
    cnt -= a

Submission status: Wrong Answer

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

    return divisors


N = int(input())
A = map(int, raw_input().split())
C = [0 for j in range(N)]
ANS = []
possible = True

for j in range(N, 0, -1):
    m = A[j-1] % 2
    am = (A[j-1] + C[j-1]) % 2
    if m != am:
        if A[j-1] == 0:
            A[j-1] += 1
            ANS.append(j)
        else:
            possible = False
            break
    if 0 < A[j-1]:
        div = make_divisors(j)
        for k in div:
            if k != j:
                C[k-1] += A[j-1]

if possible:
    print(len(ANS))
    str_ANS = [str(j) for j in ANS]
    print(" ".join(str_ANS))
else:
    print("-1")

Submission status: Wrong Answer

Solution code:
N = int(input())
b_list = [int(i) for i in input().split()]

res = [0]
b_sum = 0

for i in reversed(b_list):
    if b_sum % 2 == i:
        res.append(0)
    else:
        res.append(1)
        b_sum += 1

print(b_sum)
for idx, i in enumerate(reversed(res[1:])):
    if i == 1:
        print(idx+1, end=' ')

Submission status: Wrong Answer

Solution code:
def primes(x):
  is_prime = [True] * (x + 1)
  is_prime[0] = False
  is_prime[1] = False
  for i in range(2, int(x**0.5) + 1):
    if not is_prime[i]:
      continue
    for j in range(i * 2, x + 1, i):
      is_prime[j] = False
  return [i for i in range(x + 1) if is_prime[i]]

n=int(input())
P=primes(n)
pp=len(P)
A=[int(i) for i in input().split()]
Ans=[]
C=[False]*n
for i in reversed(range(n)):
  if A[i]==1:    
    if 2*(i+1)>n:
      Ans.append(i+1)
      C[i]=True
    else:
      c=1
      j=0
      while j<pp and P[j]*(i+1)<=n:
        if C[P[j]*(i+1)-1]==True:
          c^=1
        j+=1
      if c==1:
        Ans.append(i+1)
        C[i]=True
  elif A[i]==1:    
    c=0
    j=0
    while j<pp and P[j]*(i+1)<=n:
      if C[P[j]*(i+1)-1]==True:
        c^=1
      j+=1
    if c==1:
      Ans.append(i+1)
      C[i]=True
if len(Ans)==0:
  print(0)
else:
  print(len(Ans))
  Ans.sort()
  print(*Ans)

Submission status: Wrong Answer

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

b=[-1]*N
b[N-1]=a[N-1]
for i in range(N-1)[::-1]: #N=4なら 2,1,0
    sum_count = N // (i+1)
    if sum_count==1:
        b[i]=a[i]
    else:
        sum1=0
        for j in range(sum_count-1):
            sum1 = sum1 + b[(i+1)*(j+1)]
        sum1 = sum1 % 2
        b[i]=(a[i]+ sum1)%2

print(sum(b))
for i in range(N):
    if b[i]==1:
        print(i+1,end=" ")

Submission status: Wrong Answer

Solution code:
n=input()
arr=[0]+map(int,raw_input().split())
b=[0]*(n+1)
m=0
ans=True
for i in range(n,0,-1):
    s=0
    for j in range(i,n+1,i):
        s+=arr[j]
    if s%2==arr[i]:
        b[i]=arr[i]
        if arr[i]==1:
            m+=1
    else:
        b[i]=arr[i]^1
        if arr[i]==0:
            m+=1
if arr==b:
    print m
    print '1'*m
else:
    print 0

Submission status: Wrong Answer

Solution code:
import numpy as np

n = int(input())
a = np.array(list(map(int, input().split())))
result = np.zeros(n, dtype=np.int)

count = 0

for i in range(n-1, -1, -1):
    if i != 0:
        if np.sum(result[i:n:i]) % 2 != a[i]:
            result[i] = 1
            count += 1
    if i == 0:
        if np.sum(result) % 2 != a[0]:
            result[0] = 1
            count += 1
print(count)
print(" ".join([str(i) for i in tuple(np.nonzero(result)[0]+1)]))

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
B = [0]*N
for i, a in enumerate(A[::-1]):
    if N - i > N // 2:
        B[-(i+1)] = 1 if a == 1 else 0
    else:
        x = N-1
        n = 2
        c = 0
        while N >= x*n:
            if B[x*n-1] == 1:
                c += 1
            n += 1
        if c % 2 == 1:
            B[-(i + 1)] = 0 if a == 1 else 1
        else:
            B[-(i + 1)] = 1 if a == 1 else 0

M = B.count(1)
if M:
    ans = []
    print(M)
    for i, v in enumerate(B):
        if v == 1:
            ans.append(i+1)
    print(*ans)
else:
    print(0)

Submission status: Wrong Answer

Solution code:

import numpy as np
n = int(input())
a = np.array(list(map(int, input().strip().split())))

b = np.zeros((n))

for i in range(n):
    b[i] = a[i]

#print(b)

if n % 2 == 0:
    p = int(np.ceil(n/2))
else:
    p = int(np.ceil(n/2)-1)
#print(p)

for i in reversed(range(p+1)):
    for j in reversed(range(1,int(n/(i+1)))):
        #print(i,j)
        b[i] -= b[(i+1)*(j+1)-1]

b = b.astype(int)

#print(b)

flag = True
for i in range(n):
    if b[i] < 0:
        flag = False
        break

if flag:
    print(str(b).replace('[','').replace(']','').replace(' 0',''))

else:
    print(-1)

Submission status: Wrong Answer

Solution code:
import numpy as np
n = int(input())
a = np.array(list(map(int,input().split())))

primes = []
if sum(a)==0:
    print('0')
    exit()
for i in range(n-1,-1,-1):
    num = i + 1
    # print(primes)
    if a[i]==1:
        if len(primes) == 0:
            prime = num
            primes.append(num)
        else:
            cnt = 0
            for prime in primes:
                if prime%num==0:
                    cnt+=1
            if cnt%2==0 and cnt>1:
                print('-1')
                exit()
            if cnt==0:
                primes.append(num)

print(len(primes))
print(*primes)

Submission status: Wrong Answer

Solution code:
N = int(input())
a_l = list(map(int,input().split()))
ans_l = {}
for i,a in enumerate(a_l[::-1]):
    index = N-i
    curnum = 0
    for j in range(2,N//2):
        if(index*j<N):
           curnum += ans_l[index*j]
        else:
            break
    if(curnum%2!=a):
        ans_l[index] = 1
    else:
        ans_l[index] = 0

ans_str = ""
ans_len = 0
for key,num in ans_l.items():
    if(num==1):
        ans_str+=str(key)+" "
        ans_len+=1

print(ans_len)
if(ans_str != ""):
    print(ans_str[:-1])

Submission status: Wrong Answer

Solution code:
# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

readl= lambda: list(map(int, sys.stdin.readline().split()))
readt= lambda: tuple(map(int, sys.stdin.readline().split()))
read = lambda: sys.stdin.readline().rstrip()
readi = lambda: int(read())
readmi = lambda: map(int, sys.stdin.readline().split())
readms = lambda: map(str, sys.stdin.readline().split())

n = readi()
t = readl()
count = 0
p = []
countng = 0
for i in t:
    if i == 0:
        continue
    if i == 1:
        p.append(1)
        count += 1
    else:
        countng += 1
if countng == n:
    print(-1)
    exit()
print(count)
for i in p:
    print(i, end=" ")

Submission status: Wrong Answer

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

result = []
for i in range(N):
    if a[i] == 1:
        result.append(i + 1)
M = len(result)
print(M)
if M != 0:
    print(result[0] + 1, end = "")
    for i in range(1, M):
        print(" " + str(result[i] + 1), end = "")

Submission status: Wrong Answer

Solution code:
import numpy as np
N=int(input())
A=np.array(list(map(int,input().split())))
arr=[]
c=0
for i in range(0,N):
    vec=np.zeros(N,dtype=bool)
    vec[np.arange(i,N,i+1)]=True
    if sum(A[vec])%2==A[i]:
        c+=1
        if A[i]==1:
            arr.extend([str(i+1)])
if c==N:    
    ans=len(arr)
    print(ans)
    if ans>0:
        print(" ".join(arr))
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
def printl(a,b):
    l=[0 for i in range(b)]
    for i in a:
        l[i-1]=1
    for i in l:
        print(i,end=" ")
    print()
def factorization(n):
    arr = []
    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.append(i)
            for j in range(0,cnt):
                arr.append(i**j)
    arr.append(temp)
    arr.append(n)
    return arr
n=input()
n=int(n)
a=[int(i) for i in input().split()]
a2=[i for i in a]
l=[0 for i in range(n)]
ll=[]
if 1 in a:
    of=0
    for i in reversed(a):
        if i==1:
            x=factorization(n-of)
            for j in x:
                l[j-1]+=1
                a[j-1]=0
            ll.append(n-of)
        of+=1
    print(l)
    l=[i%2 for i in l]
    if l==a2:
        print(len(ll))
        printl(ll,n)
    else:
        print(-1)
                
else:
    print(0)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict

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

d = defaultdict(int)

def trial_division(n):

    tmp = int(n ** 0.5) + 1
    for num in range(2, tmp):
        while n % num == 0:
            d[num] += 1
            n //= num
    if n > 1:
        d[n] += 1

    return

b = [0] * N
cnt = 0
for i in range(N, 0, -1):
    if d[i] % 2 == 1 and a[i-1] == 0:
        b[i-1] = 1
        cnt += 1
        trial_division(i)
    elif d[i] % 2 == 0 and a[i-1] == 1:
        b[i-1] = 1
        cnt += 1
        trial_division(i)

if a[0] == 1:
    cnt += 1
    b[0] = 1
print(cnt)
for i in range(N):
    if b[i] == 1:
        print(i+1,end=' ')

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int,input().split()))
sum_a = []
flag = True
for i in range(N):
    sum_a.append(sum(a[i:len(a):i+1])%2)

for i in range(N):
    if a[i] != sum_a[i]:
        flag == False
if flag:
    M = sum(a)
    if M == 0:
        print(0)
    else:
        print(M)
        for i in range(N):
            if a[i] == 1:
                print('{} '.format(i+1),end='')
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
import math

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

for i in range(N):
	if i > N/2:
		if a[i]==1:
			print(1)
			print(i)
			break;
		else:
			print(-1)
			break;

	else:
		cnt = 0
		for j in range(N//(i+1)):
			if a[(i+1)*j]==1:
				cnt += 1
				b.append(a[(i+1)*j])

		if cnt%2 == a[i]:
			print(1)
			for k in range(cnt):
				print(b[k])
			break;
		else:
			print(-1)
			break;

Submission status: Wrong Answer

Solution code:
from sys import stdin

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

    ans = []
    for i in range(N, 0, -1):
        n = i * 2
        if n <= N:
            if A[i-1] % 2 != A[n-1] % 2:
                ans.append(i)
        else:
            if A[i-1] % 2:
                ans.append(i)
    print(len(ans))
    if ans:
        print(*ans)

input = lambda: stdin.readline()
main()

Submission status: Wrong Answer

Solution code:
n = int(input())
dat = list(map(int, input().split()))
res = [0] * n
#print("dat: {0}".format(dat))
for i in range(n, 0, -1):
    # i-1で参照すること
    #print(i)
    t = 0
    for j in range(0, n // i):
        #print("add:{0}".format( str( ((j+1) * i) -1 )  ))
        t += res[ ((j+1) * i) -1]

    #print("i[{0}]:  t = {1}".format(i, t))

    if t % 2 == 1:
        if dat[i-1] == 1:
            res[i-1] = 0
        else:
            res[i-1] = 1
    else:
        if dat[i-1] == 1:
            res[i-1] = 1
        else:
            res[i-1] = 0

    #print(res[i-1])
    #print("res: {0}".format(res))

#print(res)

c = 0
for i in range(n):
    if res[i] == 1:
        c += 1

resl = []
resc = c
for i in range(n):
    if c == 0:
        break
    if res[i] == 1:
        c -= 1
        resl.append("1")
    else:
        resl.append("0")

print(resc)
if resc !=0:
    print(" ".join(resl))

Submission status: Wrong Answer

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

    return divisors


N = int(input())
A = map(int, raw_input().split())
C = [0 for j in range(N)]
ANS = []
possible = True

for j in range(N, 0, -1):
    m = A[j-1] % 2
    am = (A[j-1] + C[j-1]) % 2
    if m != am:
        if A[j-1] == 0:
            A[j-1] += 1
            ANS.append(j)
        else:
            break
    if 0 < A[j-1]:
        div = make_divisors(j)
        for k in div:
            if k != j:
                C[k-1] += A[j-1]

if possible:
    print(len(ANS))
    str_ANS = [str(j) for j in ANS]
    print(" ".join(str_ANS))
else:
    print("-1")

Submission status: Wrong Answer

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, N, i):
                        if (j + 1) % (i + 1) == 0:
                                tmp += a[j]
        else:
                tmp = sum(a[1:])
        if tmp % 2 != a[i]:
                ball[i] = 1

print(sum(ball))
for i in range(N):
        if ball[i] == 1:
                print(i+1, end = " ")

Submission status: Wrong Answer

Solution code:
def Solve():
    N=int(input())
    L=[int(x) for x in input().split()]
    for i in range(N):
        j=i+1
        if sum(L[i::j])%2-L[i]:#ちがったらTrue
            print(-1)
            return
    print(sum(L))
    result=""
    for i,a in enumerate(L):
        if a:
            result+=str(i+1)
            result+=" "
    if result:
        print(result)
    
Solve()

Submission status: Wrong Answer

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

for i in range(int(n/2),n):
    b[i]=a[i]

for i in reversed(range(1,int(n/2))):
    c=0
    if a[i]==0:
        for j in range(2*i,n,i):
            if a[j]==1:
                c=c+1
        if c % 2 ==0:
            b[i]=0
        else:
            b[i]=1
    if a[i]==1:
        for j in range(2*i,n,i):
            if a[j]==1:
                c=c+1
        if c % 2 ==0:
            b[i]=1
        else:
            b[i]=0


sum=0
for k in range(1,n):
    if b[k]==1:
        sum=sum+1

if a[0]==0:
    if sum % 2 ==0:
        b[0]=0
    else:
        b[0]=1
if a[0]==1:
    if sum % 2 ==0:
        b[0]=1
    else:
        b[0]=0

if any(b)==False:
    print(0)
else:
    def func1(lst, value):
        return [i for i, x in enumerate(lst) if x == value]
    idx=func1(b,1)
    idx=map(lambda x: x+1,idx)
    print(' '.join(map(str, idx)))

Submission status: Wrong Answer

Solution code:
N = int(input())

a = list(map(int, input().split()))
b = [0] * N
flag = True
for k in range(N):
    i = N - k
    count = 0
    for m in range(i, N, i):
        count += b[m - 1]
    if count % 2 == a[i - 1]:
        pass
    elif (count + 1) % 2 == a[i - 1]:
        b[i - 1] = 1
    else:
        print(-1)
        flag = False
        break

if flag:
    print(sum(b))
    for i in range(N):
        if b[i] == 1:
            print(i + 1, end=" ")
    print()

Submission status: Wrong Answer

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

for i in range(N, 0, -1):
    if sum(A[2*i-1::i]) % 2 != A[i-1]:
        count+=1
        if ans:
            ans += " " + str(i)
        else:
            ans = str(i)

print(count)
if ans:
    print(ans)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import numpy as np

def main():
    # # 整数の入力
    # a = int(input())
    # # スペース区切りの整数の入力
    # b, c = map(int, input().split())
    # # 文字列の入力
    # s = input()
    # # 出力
    # print("{} {}".format(a+b+c, s))
    N = int(input())
    a_list = [int(i) for i in input().split()]
    b_list = [0] * N
    ret_b = []

    # a_listの後ろから順に検討していき，箱にボールをいれるかどうかが
    # 決定していく
    for i, a in enumerate(a_list[::-1]):
        index = N -1 - i # N-1 --> 0
        ball_sum = get_sum(index, b_list)
        if ball_sum % 2 != a:
            b_list[index] = 1
            ret_b.append(index + 1)
    print(len(ret_b))
    if len(ret_b)>0:
        print(' '.join(map(str, ret_b)))




def get_sum(index, b_list): # index: 0-(N-1)
    index_ = index + 1
    cur = index_
    ret_sum = 0
    while (cur<len(b_list)):
        ret_sum += b_list[cur-1]
        cur += index_
    return ret_sum


if __name__=='__main__':
    main()

Submission status: Wrong Answer

Solution code:
# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

readl= lambda: list(map(int, sys.stdin.readline().split()))
readt= lambda: tuple(map(int, sys.stdin.readline().split()))
read = lambda: sys.stdin.readline().rstrip()
readi = lambda: int(read())
readmi = lambda: map(int, sys.stdin.readline().split())
readms = lambda: map(str, sys.stdin.readline().split())

n = readi()
t = readl()
count = 0
p = []
for i in t:
    if i == 0:
        continue
    if i == 1:
        p.append(1)
        count += 1
    else:
        print(-1)
        exit()
print(count)
for i in p:
    print(i, end=" ")

Submission status: Wrong Answer

Solution code:
import copy

N = int(input())

a = [int(x) for x in input().split()]
b = copy.copy(a)

for i in range(N//2, 0, -1):
    num = 0
    for j in range(2*i, N, i):
        num += b[j-1]
    if a[i-1] == divmod(num, 2)[1]:
        b[i-1] = 0
    else:
        b[i-1] = 1


ret = []
for i in range(N):
    if b[i] == 1:
        ret.append("{}".format(i+1))
print(len(ret))
print(" ".join(ret))

Submission status: Wrong Answer

Solution code:
def get_divisor(n):
    out = []
    for i in range(n-1, 0, -1):
        if i % n == 0:
            out.append(i)
    return out

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

B = [False] * n

for i in range(n, 0, -1):
    divisors = get_divisor(i)
    B[i-1] = bool(A[i-1]) ^ bool(sum(B[divisor-1] for divisor in divisors) % 2)

out = [str(i) for i in range(n) if B[i-1] == True]

print(sum(B))
print(" ".join(out))

Submission status: Wrong Answer

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

balls = list()
# for i, a in enumerate(reversed(A)):
for bn in range(n, 0, -1):
    a = A[bn - 1]
    if 2*bn > n:
        if a == 1:
            balls.append(bn)
    else:
        a2 = A[2*bn - 1]
        if a != a2:
            balls.append(bn)

print(len(balls))
for bn in reversed(balls):
    print(bn)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int, input().split()))
dp = [0] * (N + 1)
for i in range(N, 0, -1):
  #print(i)
  if i > N // 2:
    dp[i] = a[i - 1]
  else:
    j = 3
    dp[i] = dp[2 * i]
    while i * j <= N:
      dp[i] = dp[i] ^ dp[i * j]
      j += 2
    dp[i] = dp[i] ^ a[i - 1]
M = 0
res2 = ""
#print(dp)
for i, v in enumerate(dp):
  if v == 1:
    M += 1
    res2 += str(i) + " "
print(M)
print(res2)

Submission status: Wrong Answer

Solution code:
def calc_sum(orig_index, index_list):
    if orig_index == 1:
        return len(index_list)
    _sum = 0
    index = orig_index*2
    while index <= N:
        if index in index_list:
            _sum += 1
        index += orig_index
    return _sum

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

boxes = []
ans = ""
for i,a in enumerate(A[::-1]):
    index = N - i
    if index <= N//2:
        if a != calc_sum(index, boxes) % 2:
            boxes.append(index)
            ans += (str(index) + " ")
    elif a == 1:
        boxes.append(index)
        ans += (str(index) + " ")

if ans=="":
    print(0)
else:
    print(ans)

Submission status: Wrong Answer

Solution code:
N, *a = map(int, open(0).read().split())

dp = [0] * N
for i in reversed(range(N)):
    cnt = sum(dp[i::i + 1])
    if cnt % 2 == a[i]:
        dp[i] = 0
    else:
        dp[i] = 1
            
if dp[0] % 2 == a[0]:
    b_bin = [i + 1 for i in range(N) if dp[i] > 0]
    print(len(b_bin))
    print(*b_bin)
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
n = int(input())
li = list(map(int,input().split()))
li = [-1] + li

dp = [-1] * (n+1)
cnt = n
tmp = 0
s = -1

for i in range(1,n+1):
    for j in range(0,n+1,cnt):
        if j == 0:
            continue
        if s == -1:
            s = j
        if dp[-i] == -1:
            dp[-i] = li[j]
        tmp += dp[j]
        #print(i,j,tmp,li[j])
    
    if tmp%2 != li[s]:
        tmp -= dp[-i]
        dp[-i] += (li[s]+1)%2
        tmp += dp[-i]
        if tmp%2 != li[s]:
            print(-1)
            exit()
    cnt -= 1
    tmp = 0
    s = -1

print(dp.count(1))
ans = list([i for i,x in enumerate(dp) if x == 1])
print(*ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
a_l = list(map(int,input().split()))
ans_l = {}
for i,a in enumerate(a_l[::-1]):
    index = N-i
    curnum = 0
    for j in range(2,N//2):
        if(index*j<N):
           curnum += ans_l[index*j]
        else:
            break
    if(curnum%2!=a):
        ans_l[index] = 1
    else:
        ans_l[index] = 0

ans_str = ""
ans_len = 0
for key,num in ans_l.items():
    if(num==1):
        ans_str+=str(key)+" "
        ans_len+=1

print(ans_len)
if(ans_str != ""):
    print(ans_str)

Submission status: Wrong Answer

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

result = []
res_ap = result.append

for i in range(N // 2, N)[::-1]:
    if a[i] == 1:
        res_ap(i)
for i in range(N // 2)[::-1]:
    j = 2 * (i + 1)
    while(j < N + 1):
        cnt = 0
        cnt += a[j - 1]
        j += i + 1
    if a[i] + cnt % 2 == 1:
        res_ap(i)
M = len(result)
print(M)
if M != 0:
    print(result[0], end = "")
    for i in range(1, M):
        print(" " + str(result[i]), end = "")

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [int(x) for x in input().split()]

flag = -1
counter = 0
total = 0

while(True):
    if counter == N // 2:
        break

    total = sum(A[i] for i in range(counter, N, counter+1))
    if total % 2 == A[counter]:
        flag = counter + 1
        break
    
    counter += 1


if flag != -1:
    res = [str(A[i]) for i in range(counter, N, counter+1) if A[i] == 1]
    print(len(res))
    if len(res) != 0:
        print(' '.join(res))
else:
    for i in range(counter, N):
        if A[i] == 1:
            flag = i
            print(1)
            print(A[i])
            break

if flag == -1:
    print(flag)

Submission status: Wrong Answer

Solution code:
n = int(input())
ai = list(map(int,input().split()))
ans = [0 for i in range(n)]

while n != 0:
  for i in range(int(n/2),n):#後半の処理
    ans[i] = ai[i]
    if ai[i] ==1:
      for j in range(int(i/2)):#前半の処理
        if(i+1)%(j+1) ==0:
          ai[j] = 1 - ai[j]
  n = int(n/2)
if ai[0] == ans[0]:
  print(sum(ans))
  if (sum(ans) == 0):
    print(0)
    exit(0)
  else:
    for i in range(len(ans)):
      if(ans[i] == 1):
        print('{} '.format(i+1),end='')
else:
  print(-1)

Submission status: Wrong Answer

Solution code:
N=int(input())
a=list(map(int,input().split()))
b=[0]*N
c=[]
cnt=0
for i in range(1,N+1)[::-1]:
  if sum(b[i-1::i])%2 != a[i-1]:
    a[i-1]=1
    c.append(i)
    cnt+=1
print(cnt)
if len(c)>0:
  print(*c,sep='\n')

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int, input().split()))
b = []
#Flag = True
for i in reversed(range(1, N+1)):
    j = 2
    count = 0
    while True:
        if i*j <= N:
            count += a[i*j-1]
            j += 1
        else:
            break
    if (a[i-1] % 2 == 0 and count%2 == 1) or (a[i-1] % 2 == 1 and count%2 == 0):
        b.append(a[i-1])
    

b.reverse()
ans = sum(b)
print(ans)
if ans != 0:
    print(*b)

Submission status: Wrong Answer

Solution code:
def solve():
    n = int(input())
    A = [0] + list(map(int, input().split()))
    for i in range(n // 2, 0, -1):
        t = len([1 for k in range(i, n + 1, i) if A[k] == 1]) & 1
        if A[i] != t:
            A[i] = 1 - A[i]
    print(sum(A))
    print(*list(A[i] for i in range(1, n + 1) if A[i]))
solve()

Submission status: Wrong Answer

Solution code:

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

print("0")

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
n = int(input())
lis = [0]
lis2 = list(map(int,input().split()))
lis_a = lis+lis2
if n %2 ==0:
    flag_a = [0] * (int(n/2)+1)
    for i in range(int(n/2),n):
        flag_a.append(lis_a[i+1])
else:
    flag_a = [0] * (int(n//2)+1)
    for i in range((n//2),n):
        flag_a.append(lis_a[i+1])


for i in range((n//2),0,-1):
    temp_sum = 0
    j = 2
    while (i*j <=n):
        temp_sum += flag_a[i*j]
        j += 1
    if temp_sum % 2 == 0:
        if lis_a[i] == 1:
            flag_a[i] = 1
        else:
            flag_a[i] = 0
    else:
        if lis_a[i] == 1:
            flag_a[i] = 0
        else:
            flag_a[i] = 1
print(flag_a.count(1))
anslis = []
for i in range(n):
    if flag_a[i] == 1:
        anslis.append(i)
strin = ""
for item in anslis:
    strin += str(item) + " "
if len(anslis):
    print(strin)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import io
import sys


def IN_S():
  return input()


def IN_I():
  return int(input())


def IN_L_I():
  return list(map(int, input().split()))


def IN_L_S():
  return list(map(str, input().split()))


def STR_SPLIT(s, n):
  for l in range(0, len(s), n):
    yield s[0 + l:n + l]


def T_IN():
  global test_str
  sys.stdin = io.StringIO(test_str[1:-1])


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


test_str = '''
100
1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0
'''


def MAIN():
  # T_IN()
  A()


def A():
  n = IN_I()
  li = IN_L_I()

  tmp = [False] * n

  for i, b in enumerate(reversed(li)):
    ci = n - i - 1
    # print("hoge:",i,b,ci)
    if b == 1 and not tmp[ci]:
      tmp[ci] = True

    if b == 0 and tmp[ci]:
      tmp[ci] = True

    if b == 1:
      for j in make_divisors(ci + 1):
        if j != ci + 1:
          tmp[j] = not tmp[j]

    # print(tmp)

  puts = [i * 1 for i, x in enumerate(tmp) if x]
  print(len(puts))
  if len(puts) > 0:
    print(" ".join([str(i + 1) for i in puts]))
  return None


def B():
  return None


def C():
  return None


MAIN()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
arr = list(map(int, input().split()))
sum_ = sum(arr)

if sum_ == 0:
	print(0)
else:
	output = []

	for i in range(1, n + 1):
		total = 0
		for j in range(i, n + 1, i):
			total += 1

		if (total - arr[i - 1]) % 2 == 0:
			output.append(i)

	if output == []:
		print(-1)
	else:
		print(len(output))
		for i in output:
			print(i, end=' ')

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
S = [0 for _ in range(N)]

S[0] = sum(A)-A[0]
for n in range(1, N):
    i = 2
    while (n+1) * i <= N:
        S[i] += A[(n+1)*i-1]
        i += 1

M = [0 for _ in range(N)]
for i in range(N):
    if A[i] + S[i] % 2 == A[i]:
        M[i] = A[i]
    else:
        print(-1)
        exit()

print(sum(M))

kugiri = False
for i in range(len(M)):
    if M[i] == 1:
        if kugiri:
            print(" ", end="")
        print(i+1, end="")
        kugiri = True
print()