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 fractions
from collections import deque
import numbers as np
import math


def isPrime(x):
    if x < 2:
        return True
    elif x == 2:
        True
    elif x % 2 == 0:
        False

    for i in range(2, int(math.sqrt(x))+1):
        if x % i == 0:
            return False

    return True


def main():
    N = int(input())
    a = list(map(int, input().split()))
    b = a[:]
    prime_list = deque()

    for i in range(1, N+1):
        if isPrime(i):
            prime_list.appendleft(i)

    for i in reversed(range(N//2 - 1)):
        a_t = a[i]
        t_sum = 0
        for prime in prime_list:
            ids = prime * (i+1)
            if N >= ids:
                t_sum += b[ids-1]
        guuki = t_sum % 2
        if a_t == 1 and guuki == 0:
            b[i] = 1
        elif a_t == 0 and guuki == 0:
            b[i] = 0
        elif a_t == 1 and guuki == 1:
            b[i] = 0
        elif a_t == 0 and guuki == 1:
            b[i] = 1
    cnt = 0
    ret = deque()
    for i in range(N):
        if b[i] > 0:
            cnt += 1
            ret.appendleft(i + 1)
    print(cnt)
    for i in reversed(ret):
        print(i, end=' ')


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import heapq as hq
def main():
    n = int(input())
    a = list(map(int,input().split(' ')))
    ans = [0]*(n+1)
    ans_cnt = 0
    for num,i in enumerate(a[::-1]):
        cnt = 0
        for j in range(n-num,n,n-num):
            if ans[j] ==1:
                cnt += 1
        if cnt%2 != i:
            ans[n-num] = 1
            ans_cnt += 1
    print(ans_cnt)
    for num,i in enumerate(ans):
        if i:
            print(num,'',end='')

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N = int(input())
l = list(map(int,input().split(' ')))
mid = N // 2
MAP = [0]*N
ans_l = []

for i in range(N,0,-1):
    s = N // i + 1
    t = 0
    for j in range(1,s):
        t += MAP[i*j-1]
    if t%2 != l[i-1]:
        ans_l.append(str(i))
        MAP[i-1] = 1
    print(MAP)
leng = len(ans_l)
print(leng)
print(" ".join(ans_l))

Submission status: Wrong Answer

Solution code:
"""
1 2 3 4 5 6 ... N
任意のiについて
iの倍数が書かれた箱に入っているボールの個数の和を2で割ったあまりがai
"""

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

"""
1 2 3 4 5 6
0 1 0 1 0 1

i = 1  sum(As)%2 
i = 2  sum(As[::2]%2)

1    1 1 1 1 1 1 1 1 1 1
2    0 1 0 1 0 1 0 1 0 1
3    0 0 1 0 0 1 0 0 1 0
4    0 0 0 1 0 0 0 1 0 0
5    0 0 0 0 1 0 0 0 0 1
6    0 0 0 0 0 1 0 0 0 0
7    0 0 0 0 0 0 1 0 0 0
8    0 0 0 0 0 0 0 1 0 0 
9    0 0 0 0 0 0 0 0 1 0
10   0 0 0 0 0 0 0 0 0 1

後ろから決めていく？
"""
# Ar = reversed(As)
Bs = [0] * N
inball = []
for i in [N-i for i in range(N)]:
    n = N//i
    cnt = 0
    for j in [n-i for i in range(n)]:
        cnt += As[i*j-1]
        # print(i * j)
    Bs[i-1] = cnt % 2
    if cnt % 2 == 1:
        inball.append(i)

M = len(inball)
print(M)
if M > 0:
    print(*inball)

Submission status: Wrong Answer

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

n = int(input())
a = list(map(int, input().split()))
ans = [0]*n
cnt = 0
sum = 0
for i in range(1, n+1):
    dig = n//(n-i+1)
    for j in range(dig-1):
        sum += ans[(n-i+1)*(j+1)]
    dp = sum%2
    if a[n-i] == 0 and dp == 0:
        ans[i-1] = 0
    elif a[n-i] == 1 and dp == 1:
        ans[i-1] = 0
    else:
        ans[i-1] = 1
        cnt += 1
    sum = 0
print(cnt)
if cnt == 0:
    sys.exit()
for i in range(n):
    if ans[n-i-1] == 1:
        print(i+1, end=" ")

Submission status: Wrong Answer

Solution code:
def findcount(arr, x, n):
	ans = 0
	for i in range(x, n+1, x):
		ans += arr[i-1]
	print(ans)
	return ans


n = int(input())
arr = [int(j) for j in input().split()]

ans = [False]*n
for i in range(n, 0, -1):
	x = findcount(ans, i, n)
	if x%2 == arr[i-1]:
		continue
	else:
		ans[i-1] = True

count = 0
temp = []
for x in range(1, n+1):
	if ans[x-1] == True:
		temp += [x]
		count += 1

print(count)
print(*temp)

Submission status: Wrong Answer

Solution code:
import math
import operator
import collections

N = int(input())
a = [0]+list(map(int, input().split()))
ans = [0 for _ in range(N+1)]


def xor_all(a):
    ans = 0
    for i in a:
        ans ^= i
    return ans


x = 2
tmp = float(N)/x
sqrt_num = 1
i = N
while i > 0:
    if(i > tmp):
        ans_bit = xor_all(a[:i-1:-i])
        if a[i] == ans_bit:
            ans[i] = a[i]
        else:
            print("-1")
            exit()
        i -= 1
    else:
        x += 1
        tmp = math.floor(tmp)/float(x)

print(collections.Counter(ans)[1])
b = [str(i) for i, x in enumerate(ans) if x == 1]
L = ' '.join(b)
if len(b) > 0:
    print(L)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
m = int(input())
b = list(map(int, input().split()))

for i in range(m//2,m//4,-1):
    if b[i-1] == b[i*2-1]:
        b[i-1] = 0
    else:
        b[i-1] = 1



for i in range(m//4,0,-1):
    suma = b[i*2-1]
    for ii in range(i*3-1,m,i*2):
        suma += b[ii]
    if b[i-1] == suma%2:
        b[i-1] = 0
    else:
        b[i-1] = 1

print(b.count(1))
c= []
for i in range(m):
    if b[i] == 1:
        c.append(str(i+1))

print(' '.join(c))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = input().split(' ')

b = [int(x) for x in a]

c = []
for i in range(n):
    c.append(0)

d=[]

for i in range(n):
    i = n - i - 1
    s = 0
    for j in range(i+1,n):
        if (j+1)%(i+1) == 0:
            s = s + c[j]
    if s%2 != b[i]:
        c[i] = 1
        d.append(i+1)
print(len(d))
print(sorted(d))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = input().split(' ')

b = [int(x) for x in a]

c = []
for i in range(n):
    c.append(0)

d=[]

for i in range(n):
    i = n - i
    s = 0
    for j in range(i*2,n+1,i):
     #   print(i,j)
        s = s + c[j-1]
    #print('i',i,'s',s,'b',b[i-1])
    if s%2 != b[i-1]:
        c[i-1] = 1
        d.append(i)

print(len(d))
print(sorted(d))

Submission status: Wrong Answer

Solution code:
n= int(input())
A = list(map(int, input().split()))
B = [0]*n
B_sum = [0]*n
A_sum = sum(B)
count = 0
ans = False

for i in range(n):

    j = 1
    while (n-i)*j <= n:
        B_sum[n-i-1] += B[(n-i-1)*j]
        j += 1
    if B_sum[n-i-1] % 2 != A[n-i-1]:
        B[n-i-1] = 1
        count += 1
print(count)
for i in range(n):
    
    if B[i]==1:
        print(i+1, end = "")

Submission status: Wrong Answer

Solution code:
N = int(input())
list_a = list(map(int, input().split()))
ans_list = [-1 for _ in range(N)]
for i in range(N):
  n = N-i
  if N//n == 1:
    ans_list[n-1] = list_a[n-1]
  else:
    sum_ = sum([list_a[j] for j in range(N) if j%n == 0 and j//n > 1])
    if sum_%2 == list_a[n-1]:
      ans_list[n-1] = 0
    else:
      ans_list[n-1] = 1
b = sum(ans_list)
print(b)
if b !=0:
  print(ans_list.index(1)+1)

Submission status: Wrong Answer

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

a_count = len(a_list)

boll_list = [0] * n

for rev_index, a in enumerate(reversed(a_list)):
    index = a_count - rev_index - 1
    if (index + 1) * 2 > a_count:
        boll_list[index] = a_list[index]
    else:
        divide_max = a_count // (index + 1)
        total = 0
        for divide in range(divide_max):
            total += boll_list[(index + 1) * (divide + 1) - 1]
        if a_list[index] != total % 2:
            boll_list[index] = 1

if 1 in boll_list:
    output_list = []
    for index, i in enumerate(boll_list):
        if i == 1:
            output_list.append(str(index + 1))
    print(' '.join(output_list))
else:
    print('0')

Submission status: Wrong Answer

Solution code:
import math

N = int(input())

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

bb = aa[:]

i = math.floor(N / 2) - 1

while i >= 0:
    x = (i + 1) * 2
    a = i + 1
    isKisu = bb[x - 1] % 2
    while x <= N:
        isKisu = (isKisu + bb[x - 1]) % 2
        x += a

    if aa[i] == 1:  # 自分が奇数
        if isKisu == 0:  # 2倍が偶数
            bb[i] = 1
        else:  # 2倍が奇数
            bb[i] = 0
    else:  # 自分が偶数
        if isKisu == 0:  # 2倍が偶数
            bb[i] = 0
        else:  # 2倍が奇数
            bb[i] = 1
    i -= 1

bbKisu = list(filter(lambda n: n % 2 == 1, bb))
count = len(bbKisu)

print(count)
for i in range(N):
    if bb[i] == 1:
        print(i + 1)

Submission status: Wrong Answer

Solution code:
import sys

def input():
    return sys.stdin.readline().rstrip()

if __name__ == "__main__":
    n = int(input())
    al = list(map(int, input().split()))

    nums = [0] * n
    for i in range(n, 0, -1):
        if sum(nums[i-1::i]) % 2 != al[i-1]:
            nums[i-1] = 1

    print(sum(nums))
    [print(i) for i in nums if i == 1]

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

def dq(N, Alist):
    Blist = [0]*(N//2+1)+Alist[N//2:]
    Alist = [0]+Alist
    for ind in range(N//2, 0, -1):
        total = 0
        for i in range(ind, N+1, ind):
            total += Blist[i]
        if total%2 == Alist[ind]:
            if Alist[ind] == 1:
                print(-1)
                return
        else:
            if Alist[ind] == 0:
                print(-1)
                return
            else:
                Blist[ind] = 1
    retnum = 0
    retind = []
    for ind, bi in enumerate(Blist):
        if bi == 1:
            retnum +=1
            retind.append(str(ind))
    print(retnum)
    if retnum > 0:
        print(" ".join(retind))
dq(N,Alist)

Submission status: Wrong Answer

Solution code:
import sys
MAX_INT = int(10e12)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

import functools
@functools.lru_cache(maxsize=None)
def make_divisors(n):
  divisors = []
  for i in range(int(n**0.5)+1,0,-1):
    if n % i == 0:
      divisors.append(i)
      divisors.append(n//i)
  return list(set(divisors))

N = I()
a = IL()
cnt = [0]*N

ans = ""
M = 0
for i in range(N-1,-1,-1):
  if cnt[i]%2 == 0 and a[i] == 1 or cnt[i]%2 == 1 and a[i] == 0:
    M += 1
    ans += str(i+1) + " "
  if a[i] == 1:
    l = make_divisors(i+1)
    for j in l:
      cnt[j-1] += 1

if ans == "":
  print(0)
else:
  print(M)
  print(ans[:-1])

Submission status: Wrong Answer

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

a_count = len(a_list)

boll_list = [0] * n

for rev_index, a in enumerate(reversed(a_list)):
    index = a_count - rev_index - 1
    if a * 2 > a_count:
        boll_list[index] = a_list[index]
    else:
        divide_max = a_count // (index + 1)
        total = 0
        for divide in range(divide_max):
            total += boll_list[(index + 1) * (divide + 1) - 1]
        if a_list[index] != total % 2:
            boll_list[index] = 1

if 1 in boll_list:
    output_list = []
    for index, i in enumerate(boll_list):
        if i == 1:
            output_list.append(str(index + 1))
    print(' '.join(output_list))
else:
    print('0')

Submission status: Wrong Answer

Solution code:
import sys
def input():
    return sys.stdin.readline()[:-1]
N = int(input())
A = list(map(int, input().split()))

chk = [0]*N

A.reverse()
for i, a in enumerate(A):
    sum_chk = sum(chk[N-i-1::N-i])
    if sum_chk == a-1:
        chk[N-i-1] = 1
        continue
    elif sum_chk == a:
        continue
    else:
        print(-1)
        exit()

M = sum(chk)
b = [i+1 for i, v in enumerate(chk) if v==1]
print(M)
if M != 0: print(*b)

Submission status: Wrong Answer

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


lst = []
tmp = N
for i in range(-(-(tmp-1)//2), tmp):
    if A[i]==1:
        lst.append(i+1)
        
tmp = tmp//2

while tmp!=0:
    for i in range(-(-(tmp-1)//2), tmp):
        if A[2*i+1]==1:
            if A[i]==0:
                lst.append(i+1)
        else:
            if A[i]!=0:
                lst.append(i+1)
            
    tmp = tmp//2

if A[0]==1:
    if len(lst)%2==0:
        lst.append(1)
else:
    if len(lst)%2!=0:
        lst.append(1)
                   
print(len(lst))
for j in range(len(lst)):
    print(lst[j], end=" ")

Submission status: Wrong Answer

Solution code:
N = int(input())
ans = 0
lst = list(map(int, input().split()))
slice_lst = lst[:int(N / 2)]
for i,k in enumerate(reversed(slice_lst)):
  sub_lst = lst[len(slice_lst)-i-1:len(lst):len(slice_lst)-i]
  if (k != sum(sub_lst) % 2):
    if (k == 0):
      lst[len(slice_lst)-i-1] = 1
    else:
      ans = -1
      break

if (ans == -1):
  print(ans)
else:
  ans_lst = []
  for i,k in enumerate(lst):
    if (k == 1):
      ans_lst.append(str(i+1))
  print(len(ans_lst))
  result = ' '.join(ans_lst)
  print(result)

Submission status: Wrong Answer

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

ans=[]
for i in range(n-1,n//2-1,-1):
  if li[i]==1:
    ans.append(i+1)

for i in range(n//2,0,-1):
  count=0
  for j in ans:
    if j%i==0:
      count+=1
  if count%2==0:
    ans.append(i)
ans.reverse()
print(len(ans))
L=[str(a) for a in ans]
L=" ".join(L)
if len(L)!=0:
  print(L)

Submission status: Wrong Answer

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

F = set()
for n in range(N, 0, -1):
    a = sum([A[i] for i in range(2 * n, N + 1, n)]) % 2
    if a % 2 != A[n]:
        F.add(n)

print(len(F))
L = list(map(str, F))
print(" ".join(L))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
ans = []
for i in range(N) :
    num = i+1
    
    if num**2 > N :
        if A[i] == 1:
            ans.append(num)
    
    cnt = 0
    for j in range(N) :
        if (j+1) % num == 0 :
            cnt += A[j]
    
    if cnt % 2 != A[i] :
        ans = -1
        break
    
    if cnt % 2 == 1 :
        ans.append(i+1)

if ans == -1 :
    print(ans)
else :
    print(len(ans))
    print(*ans, sep="\n")

Submission status: Wrong Answer

Solution code:
n = int(input())
ai = [int(x) for x in input().split()]
bn = [0] * n
cn = [0] * n

for i in range(0,n):
    j = n - 1 - i
    if (n//(j+1)<1):
        bn[j] = ai[j]
    else:
        bn[j] = (cn[j] + ai[j]) % 2

    if bn[j] == 1 and not(n//(j+1) < 1):
        for k in range(0,((j+1)//2)+1):
            if (j+1)%(k+1) == 0:
                cn[k] += 1

m = sum(bn)
print(m)
for i in range(0,n):
    if bn[i] == 1:
        print(i+1, end=" ")

print(bn)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
n = int(input())
a = [0] + list(map(int, input().split()))
b = [0 for i in range(n + 1)]

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

ans = sum(b)
print(ans)
if ans > 0:
    print(" ".join([str(i) for i, x in enumerate(b) if x == 1]))

Submission status: Wrong Answer

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

F = set()
for n in range(N, 0, -1):
    a = sum([A[i] for i in range(2 * n, N + 1, n)]) % 2
    if a != A[n]:
        F.add(n)

print(len(F))
L = list(map(str, F))
print(" ".join(L))

Submission status: Wrong Answer

Solution code:
def inpl():
    return list(map(int, input().split()))


def func(n):
    # print(n)
    tmp = n + n
    a = 0
    while tmp <= N:
        a += ans[tmp - 1]
        tmp += 1
        tmp += n
    return a % 2


N = int(input())
A = inpl()
ans = [0 for i in range(N)]

for i in reversed(range(N)):
    if func(i + 1) != A[i]:
        ans[i] = 1

# print(ans)
B = []
for i in range(N):
    if ans[i] == 1:
        B.append(i + 1)

print(len(B))
if len(B) > 0:
    print(" ".join(map(str, B)))

Submission status: Wrong Answer

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

for i in range(n-1, -1, -1):
  if n // (i+1) == 1:
    if a[i] == 1:
      b.append(i+1)
  elif (n // (i+1)) == (n / (i+1)):
    m = 0
    for j in range(1, n // (i+1) + 1):
      m += a[i * j - 1]
    m = m // 2
    if a[i] != m:
      b.append(i+1)
      
print(len(b))
if len(b) != 0:
  for bb in b:
    print(bb)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [int(i) for i in input().split()]
b = [0] * n
f = 0
for i in sorted(list(range(n)),reverse=True):
	if a[i] == 1:
		k = n//(i+1)
		if k == 1:
			b[i] = 1
		else:
			c = 0
			for j in range(0,k):
				c+=b[i+(j*i)]
			if c % 2 == 0:
				b[i] = 1
print(sum(b))
for i in range(len(b)):
	if b[i] == 1:
		print(i+1)

Submission status: Wrong Answer

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

ans=[]
cnt=0
B = [0 for i in range(N)]
import math
for i in range(math.floor(N/2),N):
    B[i]=A[i]
    if(A[i]==1):
        cnt+=1
        ans.append(i)
        
from functools import reduce
for i in range(math.floor(N/2)-1,-1,-1):
    R=[B[(i+1)*j-1] for j in range(2,(N//(i+1))+1)]
    r=sum(R)%2
    l = int(not (r)) if A[i]==1 else int(r)
    B[i]=l
    if l==1:
        cnt+=1
        ans.append(i)
print(cnt)
if cnt>0:
    print(" ".join(map(str, ans)))

Submission status: Wrong Answer

Solution code:
N = int(input())
l = list(map(int,input().split(' ')))
mid = N // 2
MAP = [0]*N
ans_l = []

for i in range(N,0,-1):
    s = N // i + 1
    t = 0
    for j in range(1,s):
        t += MAP[i*j-1]
    if t%2 != l[i-1]:
        ans_l.append(str(i))
        MAP[i-1] = 1
leng = len(ans_l)
print(leng)
if leng==0:
    print(0)
else:
    print(" ".join(ans_l))

Submission status: Wrong Answer

Solution code:
import math
N = int(input())
ax = list(map(int,input().split()))

boxin = []
bx = [0 for _ in range(N+1)]
for cnt in range(N, 0, -1):
    a = ax[cnt-1]
    tmp = 0
    for tmp_cnt in range(cnt*2, N, cnt):
        if bx[tmp_cnt] != 0:
            tmp += 1
    
    if tmp % 2 != a:
        boxin.append(cnt)
        bx[cnt] = 1

box = len(boxin)
print(box)
if box != 0:
    boxin.reverse()
    print(' '.join(map(str, boxin)))

Submission status: Wrong Answer

Solution code:
a = int(input())

print(1)

b = ""
c = b.zfill(a)

print(c)

Submission status: Wrong Answer

Solution code:
import fractions
from collections import deque
import numbers as np
import math


def isPrime(x):
    if x < 2:
        return True
    elif x == 2:
        True
    elif x % 2 == 0:
        False

    for i in range(1, int(math.sqrt(x))+1):
        if x % i == 0:
            return False

    return True


def main():
    N = int(input())
    a = list(map(int, input().split()))
    b = a[:]
    prime_list = deque()

    for i in range(1, N+1):
        if isPrime(i):
            prime_list.appendleft(i)

    for i in reversed(range(N//2 - 1)):
        a_t = a[i]
        t_sum = 0
        for prime in prime_list:
            ids = prime * (i+1)
            if N >= ids:
                t_sum += b[ids-1]
        guuki = t_sum % 2
        if a_t == 1 and guuki == 0:
            b[i] = 1
        elif a_t == 0 and guuki == 0:
            b[i] = 0
        elif a_t == 1 and guuki == 1:
            b[i] = 0
        elif a_t == 0 and guuki == 1:
            b[i] = 1
    cnt = 0
    ret = deque()
    for i in range(N):
        if b[i] > 0:
            cnt += 1
            ret.appendleft(i + 1)
    print(cnt)
    for i in reversed(ret):
        print(i, end=' ')


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

a.insert(0, 0)
b.insert(0, 0)

n = int(N/2)

for i in range(N, 0, -1):
    nums = 0

    for ii in range(2, int(N/i)):
        nums += b[i*ii - 1]

    if nums % 2 != a[i]:
        b[i] += 1

sum_b = sum(b)
print(sum_b)

flag = False
for i, bb in enumerate(b):
    if i == 0:
        continue

    if bb != 0:
        flag = True
        print(i, end=' ')

if flag:
    print()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
n = int(input())
a = [0] + list(map(int, input().split()))
b = [0 for i in range(n + 1)]

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

ans = sum(b)
print(ans)
if ans > 0:
    print(" ".join([str(i) for i, x in enumerate(b) if x == 1]))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import math
N = int(input())
ax = list(map(int,input().split()))

boxin = []
bx = [0 for _ in range(N+1)]
for cnt in range(N, 0, -1):
    a = ax[cnt-1]
    tmp = 0
    for tmp_cnt in range(cnt*2, N, cnt):
        if bx[tmp_cnt] != 0:
            tmp += 1
    
    if tmp % 2 != a:
        boxin.append(cnt)

box = len(boxin)
print(box)
if box != 0:
    boxin.reverse()
    print(' '.join(map(str, boxin)))

Submission status: Wrong Answer

Solution code:
import sys
n=int(input())
a=list(map(int,input().split()))
b=[]
d=[]
ans=0
e=0
if a[0]==1:
  c=1
if a[0]==0:
  c=+0
b.append(c)
c=0
A=a.count(1)
if a[0]==0 and A>0:
  print("-1")
for i in range(2,n+1):
  for j in range(i-1,(n//i)*i,i):
    if a[j]==1:
      c+=1
  b.append(c)
  c=0
for k in range(n):
  if b[k]==1:
    ans+=1
    d.append(1)
  else:
    e+=1
if e==1:
  print("-1")
else:
  print(ans)
  if ans!=0:
    for p in range(len(d)):
      print(d[p], end=' ')

Submission status: Wrong Answer

Solution code:
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

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

for i in reversed(range(N)):
    if A[i] != B[i]:
        put.append(i+1)
        # iを素因数分解して、約数に1をxorしていく
        tmp = 1
        n = i+1
        if n == 1:
            continue
        while tmp*tmp <= n:
            if n % tmp == 0:
                B[tmp-1] ^= 1
            tmp += 1


if len(put) > 0:
    print(len(put))
    print(*put)
else:
    print(0)

Submission status: Wrong Answer

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

res = [0]
sum_dict = {i: 0 for i in range(1, N+1)}

for idx, i in enumerate(reversed(b_list)):
    if sum(res[N-1-idx: N: N-idx]) % 2 == i:
        res.append(0)
    else:
        res.append(1)
        sum_dict[len(b_list) - idx] += 1

print(sum(res))
del res[0]

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

Submission status: Wrong Answer

Solution code:
N = int(input())
l = list(map(int,input().split(' ')))
mid = N // 2
MAP = [0]*N
ans_l = []

for i in range(N,0,-1):
    s = N // i + 1
    t = 0
    for j in range(1,s):
        t += MAP[i*j-1]
    if t%2==0:
        if l[i-1]%2==1:
            ans_l.append(str(i))
            MAP[i-1] = 1
    else:
        if l[i-1]%2==0:
            ans_l.append(str(i))
            MAP[i-1] = 1

leng = len(ans_l)
print(leng)
if leng==0:
    print(0)
else:
    print(" ".join(ans_l))

Submission status: Wrong Answer

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

n = int(input())

a = [0]
for i in input().split(' '):
    a.append(int(i))

#そのままにするやつ
jissai_box = []

b = [0] * (n+1)

for i in range(n, 0, -1):
    num = i

    #該当するやつ
    gaito_num = n // i
    ll = 0
    j = 0
    while i * j < n:
        j+=1
        ll += b[i]

    if ll % 2 != a[i]:
        b[i] = 1
        jissai_box.append(i)

    #print([a[p * i] for p in range(gaito_num)], p % 2, a[i], p % 2 != a[i])

#for i in range(n//2, n):
#    if i == 1:
#        b.append(i)

print(len(jissai_box))

for i in jissai_box:
    print(i, end="")
print('')

Submission status: Wrong Answer

Solution code:
import numpy as np


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


N = int(input())
# N=10**5
# a=np.random.randint(0,2,N)
a = acinput()
a.insert(0,0)
tmp=[0 for i in range(N+1)]
b = np.array(tmp)

aaa=int(np.ceil(N/2))
for i in range(aaa,N+1):
    b[i] = a[i]

res = 0
for k in reversed(range(1, int(N/2)+2)):
    #print(k)
    r = np.arange(k, N, k)
    b[k] = (a[k]+np.sum(b[r])) % 2


res=[]
count=0
for sb in range(1,N+1):
    if b[k]!=0:
        count+=1
        res.append(b[k])



print(count)
if count>0:
    print(" ".join(list(map(str,res))))

Submission status: Wrong Answer

Solution code:
import logging

logging.basicConfig(level=logging.INFO, format="%(message)s")
#logging.disable(logging.CRITICAL)

def main():
    N = int(input())
    a_ = list(map(int, input().split()))
    box = [0 for _ in range(N)]

    logging.info("Hello!")

    for i in range(N):
        box_num = N - i

        sum = 0
        for j in range((N // (box_num)) - 1):
            sum += a_[(box_num) * (j + 2) - 1]
            
        box[box_num - 1] = abs(a_[box_num - 1] - (sum % 2))

    logging.info(box)

    
    print(box.count(1))
    answer = ""
    for i in range(N):
        if box[i] == 1:
            answer += str(i + 1)
            answer += " "

    print(answer)
    
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys
import math

def add_ball(idx):
    b_list[idx] = (b_list[idx]+1)%2
    if idx > 0:
        b_list[0] = (b_list[0]+1)%2
        idx += 1 # 0-origin to 1-origin
        for j in range(2, int(math.sqrt(idx))+2):
            if idx%j == 0:
                k = int(idx/j)
                if j == k:
                    b_list[j-1] = (b_list[j-1]+1)%2
                    break
                elif j < k:
                    b_list[j-1] = (b_list[j-1]+1)%2
                    b_list[k-1] = (b_list[k-1]+1)%2
                else:
                    break


if __name__ == "__main__":
    input = sys.stdin.readline

    n = int(input())
    a_list = list(map(int, input().split()))
    b_list = [0] * n
    for i, a in enumerate(a_list[::-1]):
        if a != b_list[-i-1]:
            add_ball(n-i-1)
    ball_sum = sum(b_list)
    ball_list = [i+1 for i, b in enumerate(b_list) if b == 1]
    print(ball_sum)
    if ball_sum > 0:
        print(' '.join(map(str, ball_list)))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

a.insert(0, 0)
b.insert(0, 0)

n = int(N/2)

for i in range(N, 0, -1):
    nums = 0

    for ii in range(2, int(N/i)):
        nums += b[i*ii - 1]

    if nums % 2 != a[i]:
        b[i] += 1

sum_b = sum(b)
print(sum_b)

flag = True
for i, bb in enumerate(b):
    if i == 0:
        continue

    if bb != 0:
        flag = False
        print(i, end=' ')

if flag:
    print()