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())
data = [int(_) for _ in input().split(" ")]

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

#half
half_index = n//2

for i in range(half_index,n):
    ans[i] = data[i]

for i in range(half_index-1,-1,-1):
    count = n//(i+1)
    ans[i] = data[i]
    while count != 1:
        ans[i] = ans[i] - ans[count*i-1]
        count -= 1

count = 0
for _ in ans:
    if _ != 0:
        count += 1

print(count)

ans2 = ["1" for i in range(count)]
if sum(ans) != 0:
    print(" ".join(map(str,ans2)))

Submission status: Wrong Answer

Solution code:
n = int(input())
data = [int(_) for _ in input().split(" ")]

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

#half
half_index = n//2

for i in range(half_index,n):
    ans[i] = data[i]

for i in range(half_index-1,-1,-1):
    count = n//(i+1)
    while count != 1:
        ans[i] = data[i] - ans[count*i-1]
        count -= 1

count = 0
for _ in ans:
    if _ != 0:
        count += 1

print(count)

ans2 = ["1" for i in range(count)]
if sum(ans) != 0:
    print(" ".join(map(str,ans2)))

Submission status: Wrong Answer

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

box = [0] * N
v = N // 2  # 後半部の最初のindex

for i in range(v, N):
    if ai[i] == 0:
        box[i] = 0
    else:
        box[i] = 1

for i in range(v - 1, -1, -1):
    value = i + 1
    sum = 0
    for j in range(value * 2 - 1, N, value):
        sum += box[i]
    if sum & 1 == 1:
        box[i] = 0 if ai[i] & 1 == 1 else 1
    else:
        box[i] = 0 if ai[i] & 1 == 0 else 1

print(box.count(1))
for x in box:
    if x == 1:
        print(x)

Submission status: Wrong Answer

Solution code:
n = int(input())
data = [int(_) for _ in input().split(" ")]

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

#half
if n%2 == 0:
    half_index = n//2
else:
    half_index = n//2 + 1

for i in range(half_index,n):
    ans[i] = data[i]

for i in range(half_index-1,-1,-1):
    count = n//(i+1)
    while count != 1:
        ans[i] = data[i] - ans[count*i-1]
        count -= 1

count = 0
for _ in ans:
    if _ != 0:
        count += 1

print(count)

ans2 = ["1" for i in range(count)]
if sum(ans) != 0:
    print(" ".join(map(str,ans2)))

Submission status: Wrong Answer

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

for i in range(N,0,-1):
  kari=0
  for j in range(1,N+1):
    if i*j <= N:
      kari=kari+a[i]
    else:
      break
  c[i]=kari%2
M=sum(c)
b = [i for i in range(1,N+1) if c[i] ==1]
b2 = ' '.join(map(str,b))
print(M)
if M>0:
  print(b2)

Submission status: Wrong Answer

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

for i in range(N,0,-1):
  for j in range(1,N+1):
    if i*j <= N:
      kari=kari+a[i]
    else:
      break
  c[i]=kari%2
M=sum(c)
b = [i for i in range(1,N+1) if c[i] ==1]
b2 = ' '.join(map(str,b))
print(M)
if M>0:
  print(b2)

Submission status: Wrong Answer

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

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

    ball = [0 for i in range(N+1)]

    count = 0
    for i in range(N, 0, -1):
        tmp = 0
        for j in range(i*2, N, i):
            tmp += ball[j]
        tmp %= 2
        if a[i-1] != tmp:
            ball[i] = 1
            count += 1
        else:
            ball[i] = 0
    print(count)
    for i in range(1, N):
        if ball[i] != 0:
            print(i)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [int(i) for i in input().split()]
x = [0]*n
for i in range(n,0,-1):
    m,c = 2,0
    while i*m<=n:
        c+=x[i*m-1]
        m+=1
    x[i-1] = a[i-1]-c%2
print(sum(x))
for i in range(n):
    if x[i]: print(i+1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int, input().split()))
lis = []
ans = -1
for i in range(N):
#	lis = a[::i+1]
	lis = [ i for i in a[::i+1] if i > 0 ]
	if sum(lis)%2 == a[i]:
		ans = lis
		break
print(len(ans))
[ print(i) for i in ans ]

Submission status: Wrong Answer

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

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

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

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

Submission status: Wrong Answer

Solution code:
import sys


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


def main():
    n = int(input())
    bits = [int(e) for e in input().split()]
    ans = set()
    for i in reversed(range(n)):
        if bits[i] == 1:
            ans.add(i + 1)
        for j in range(i):
            if i < j * j:
                break
            if (i + 1) % (j + 1) > 0:
                continue
            bits[i] = bits[i] ^ 1
    print(len(ans))
    print(*ans)


main()

Submission status: Wrong Answer

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

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

print(sum(b))
print(result_str[:-1])

Submission status: Wrong Answer

Solution code:
m = int(input())
s = list(map(int, input().split()))
# m = 6
# s = list(map(int, "110111"))
bs = [0] * m

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

print(cnt)
if cnt > 0:
  print(" ".join(map(str, bs)))

Submission status: Wrong Answer

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

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

print(cnt)
if cnt > 0:
  print("".join(map(str, bs)))

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

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

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

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

Submission status: Wrong Answer

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

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

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

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

Submission status: Wrong Answer

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

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

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

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

Submission status: Wrong Answer

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

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

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

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

Submission status: Wrong Answer

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

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

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

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

Submission status: Wrong Answer

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

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

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

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

Submission status: Wrong Answer

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

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

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

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

Submission status: Wrong Answer

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

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N=INT()
A=LIST()

# その位置にボールを入れるかを保持するA2
A2=[0]*N
B=[]
# 後ろから決めていく
for i in range(N-1, -1, -1):
    cur=i+1
    cnt=0
    # curの倍数を全部見に行く
    for j in range(cur*2, N, cur):
        cnt^=A2[j-1]
    # ボールを入れるべきかどうか
    if A[i]!=cnt:
        B.append(cur)
        A2[i]=1

print(len(B))
print(*B)

Submission status: Wrong Answer

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

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

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

print(len(l))
for m in l:
    print(m)

Submission status: Wrong Answer

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

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N=INT()
A=LIST()

# その位置が偶奇どちらになるかを保持するA2
A2=[0]*N
B=[]
# 後ろから決めていく
for i in range(N-1, -1, -1):
    cur=i+1
    cnt=0
    # curの倍数を全部見に行く
    for j in range(cur*2, N, cur):
        cnt^=A2[j-1]
    # ボールを入れるべきかどうか
    if A[i]!=cnt:
        B.append(cur)
        A2[i]=cnt

print(len(B))
print(*B)

Submission status: Wrong Answer

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

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

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

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

Submission status: Wrong Answer

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

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N=INT()
A=LIST()

# その位置が偶奇どちらになるかを保持するA2
A2=[0]*N
B=[]
# 後ろから決めていく
for i in range(N-1, -1, -1):
    cur=i+1
    cnt=0
    # curの倍数を全部見に行く
    for j in range(cur*2, N, cur):
        cnt^=A2[j]
    # ボールを入れるべきかどうか
    if A[i]!=cnt:
        B.append(cur)
        A2[i]=cnt

print(len(B))
print(*B)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = [int(x) for x in input().split()]
ans = []
li = [0]*N
x = 0
for ind,i in enumerate(a[N//2:]):
    if(i==1):
        ans.append(ind+1+N//2)
        li[ind+N//2] = 1
for ind,i in enumerate(a[:N//2][::-1]):
    n = N//2-ind
    if(sum(li[n-1::n])%2!=i):
        ans.append(ind+1)
ans.sort()
print(len(ans))
if(len(ans)!=0):
    print(*ans)

Submission status: Wrong Answer

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

for i in range(N-1,0,-1):
    a = aList[i]
    b = 2
    c = 0
    while i*b < N:
        if x[i*b] == 1:
            c += 1
        b+=1
    x[i] = int(c%2==0 if a == 1 else c%2==1)

# 0番目の処理
c = sum(x)
x[0] = int(c%2==0 if aList[0] == 1 else c%2==1)

# output
print(sum(x))
for i,y in enumerate(x):
    if y == 1:
        print(i+1, end=' ')

Submission status: Wrong Answer

Solution code:

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

Submission status: Wrong Answer

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

for i in range(N-1,0,-1):
    a = aList[i]
    b = 2
    c = 0
    while i*b < N:
        if x[i*b] == 1:
            c += 1
        b+=1
    x[i] = int(c%2==0 if a == 1 else c%2==1)

# 0番目の処理
c = sum(x)
x[0] = int(c%2==0 if aList[0] == 1 else c%2==1)

# output
print(sum(x))
for i,y in enumerate(x):
    if y == 1:
        print(i+1)

Submission status: Wrong Answer

Solution code:

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

Submission status: Wrong Answer

Solution code:

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


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

Submission status: Wrong Answer

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

if aList[0] != sum(aList) % 2:
    print(-1)
    quit()
for i, a in zip(range(1,N+1), aList[1:]):
    if sum(aList[i::i]) % 2 == a:
        continue
    print(-1)
    quit()

print(sum(aList))
for i,a in enumerate(aList):
    if a == 1:
        print(i+1)

Submission status: Wrong Answer

Solution code:
M=0
N=int(input())
A=list(map(int,input().split()))
A.insert(0,0)
B=[]
for i in range(N):
  i=N-i
  su=0
  for j in range(i+i,N+1,i):
    su=su^A[j]
  if su!=A[i]:
    B.append(str(i))
    M=M+1

C=[]
for i in range(len(B)):
  i=len(B)-i-1
  C.append(B[i])
print(M)
print(" ".join(C))

Submission status: Wrong Answer

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

for i in range(n, 0, -1):
    x = 0
    for j in range(i, n + 1, i):
        x ^= b[j]
    b[i] = x ^ a[i]

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

Solution code:
n=int(input())
l=list(map(int,input().split()))
l1=[0 for i in range(n)]
for i in range(1,1+(n+1)//2):
  if l[-i]==1:
    l1[-i]=1
  else:
    pass
for i in range((n+1)//2-1,-1,-1):
  s=0
  for j in range(2,n//(1+i)+1):
    if l1[(i+1)*j-1]==1:
      s+=1
  if s%2==1:
    if l[i]==0:
      l1[i]=1
  else:
    if l[i]==1:
      l1[i]=1
l2=[]
s=0
for i in range(n):
  if l1[i]==1:
    s+=1

Submission status: Wrong Answer

Solution code:
n=int(input())
l=list(map(int,input().split()))
l1=[0 for i in range(n)]
for i in range(1,1+(n+1)//2):
  if l[-i]==1:
    l1[-i]=1
  else:
    pass
for i in range(0,(n+1)//2):
  s=0
  for j in range(2,n//(1+i)+1):
    if l[(i+1)*j-1]==1:
      s+=1
  if s%2==1:
    if l[i]==0:
      l1[i]=1
  else:
    if l[i]==1:
      l1[i]=1
l2=[]
s=0
for i in range(n):
  if l1[i]==1:
    s+=1
    l2.append(str(i+1))
print(s)
print(" ".join(l2))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import math

anser=0
count=0
n  = int(input())
a = list(map(int, input().split()))
data  = []
result =[]
# for i in a[:math.floor(n/2-1):-1]:
# 	data.append(i)
# print(data)	
for i in range(n,0, -1):
	try:
		for s in range (2,math.floor(n/(i)+1)):
			count += data[-i*(s-1)]
	except IndexError:
		count = 0 
	data.append((count+a[i-1])%2)
	anser+=(count+a[i-1])%2
	count=0

print(data)
print(anser)
if anser!=0:
	for i ,j in enumerate(data[::-1]):
		if j ==1:
			result.append(i+1)
	print(' '.join(list(map(str, result))))

Submission status: Wrong Answer

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

M = 0
box = [0 for i in range(N)]
i = N - 1
while i >= 0:
    if a[i] == 1 and M % 2 == 0:
        box[i] = 1
        M += 1
    i -= 1

print(M)
for m in range(M):
    if box[m] == 1:
        print(m + 1, ' ')

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

if __name__ == "__main__":
    main13()

Submission status: Wrong Answer

Solution code:
import math

anser=0
count=0
n  = int(input())
a = list(map(int, input().split()))
data  = []
result =[]
for i in a[:math.floor(n/-1):-1]:
	data.append(i)
# print(data)
for i in range(math.floor(n/2)):
	for s in range (1,math.floor(n/(i+1)+1)):
		count += data[-i*s]
	data.append((count+a[i])%2)
	anser+=(count+a[i])%2
	count=0

print(anser)
if anser!=0:
	for i ,j in enumerate(a[::-1]):
		if j ==1:
			result.append(n-i)
	print(' '.join(list(map(str, result))))

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int, input().split()))
box = [0]*(N+1)
cnt = 0
divs = [0]*(N+1)
for n in range(1,N+1):
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divs[i] += 1
            if i != n // i: divs[n//i] += 1     
    
for i in range(N-1, -1, -1):
    if not divs[i] and divs[i]%2 != a[i]:
            box[i+1] = 1
            cnt += 1
        #print(box)
print(cnt)        
print(" ".join(map(str,[i for i,b in enumerate(box) if b])))

Submission status: Wrong Answer

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

for i in range(N-1,-1,-1):
  a = A[i]
  for j in range(i+1,N,i+1):
    if j in ans:
      a += 1
  if a % 2:
    ans.add(i+1)
print(len(ans))
print(*ans)

Submission status: Wrong Answer

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

for i in range(N-1,-1,-1):
  a = A[i]
  for j in range(i+1,N-1,i+1):
    if j in ans:
      a += 1
  if a % 2:
    ans.add(i+1)
print(len(ans))
print(*ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int, input().split()))
box = [0]*(N+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)     
    return divisors

for i in range(N-1, -1, -1):
    for div in make_divisors(i+1):
        if a[i]:
            box[i+1] ^= 1
        #print(box)
print(len(list(filter(lambda x: x, box))))
print(" ".join(map(str,[i for i,b in enumerate(box) if b])))

Submission status: Wrong Answer

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

ball = [0] * (n + 1)
for i in reversed(range(1, n)):
    if a[i] == 1:
        if sum(ball[i * 2::i]) % 2 == 0:
            ball[i] = 1
        else:
            ball[i] = 0
    else:
        if sum(ball[i * 2::i]) % 2 == 0:
            ball[i] = 0
        else:
            ball[i] = 1

ans = []
for i in range(1, n):
    if ball[i] == 1:
        ans.append(i)

print(len(ans))
if len(ans) != 0:
    for i in range(len(ans)):
        print(ans[i])

Submission status: Wrong Answer

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

b = [0]*N
for i in range(N,0,-1):
    total = 0
    for j in range(i,N+1,i):
        total+=b[i-1]
    if total%2==a[i-1]:
        b[i-1] = 0
    else:
        b[i-1] = 1
m = b.count(1)

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

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
  
def solve():
  n = int(input())
  a = list(int(i) for i in input().split())
  ans = [0]*n
  for i in range(n-1,-1,-1):
    if a[i] == 0:
      continue
    else:
      ans[i] = 1
      tmp = i+1
      div = make_divisors(tmp)
      ##print(div)
      for j in div:
        a[j-1] = 1^a[j-1]
  print(sum(ans))
  for i in range(sum(ans)):
    print(1, end=" ")
solve()

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
  
def solve():
  n = int(input())
  a = list(int(i) for i in input().split())
  ans = [0]*n
  for i in range(n-1,-1,-1):
    if a[i] == 0:
      continue
    else:
      tmp = i+1
      div = make_divisors(tmp)
      for j in div:
        ans[j-1] = 1^ans[j-1]
  print(sum(ans))
  for i in range(sum(ans)):
    print(1, end=" ")
solve()

Submission status: Wrong Answer

Solution code:
import sys

#+++++


def oaa(ll, val, oe):
	#print(ll,val,oe)
	if val == 1:
		s=sum(ll)
	else:
		c=1
		s=0
		lll=len(ll)
		s=sum(ll[val::val])
		#while c * val <= lll:
		#	s+=ll[(c*val)-1]
		#	c+=1
	return 1 if oe != s%2 else 0
		
def main():
	n = int(input())
	ll= list(map(int, input().split()))
	
	ret = [0 for _ in range(n)]
	for i in range(n):
		val=n-i
		rr=oaa(ret, val, ll[-i-1])
		ret[-i-1]=rr
	
	#print(ret)
	print(sum(ret))
	print(' '.join([str(i+1) for i,v in  enumerate(ret) if v == 1]))
		
		
	
#+++++

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
	else:
		input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Submission status: Wrong Answer

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

ans=[]
a=[0 for i in range(N+1)]

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

Submission status: Wrong Answer

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

for i in range(n,0,-1):
    if a[i] == 0:
        continue
    ans.append(i)
    cnt=2
    while(cnt*cnt<=i+2):
        if i%cnt == 0:
            if cnt == i//cnt:
                a[cnt]+=a[i]
                a[cnt]%=2
            else:
                a[cnt]+=a[i]
                a[i//cnt]+=a[i]
                a[cnt]%=2
                a[i//cnt]%=2
        cnt+=1
print(len(ans))
if len(ans)!=0:
    ans.sort()
    an = [str(a) for a in ans]
    an = ' '.join(an)
    print(an)