Problem:


Score : 400 points

Problem Statement

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

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

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

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

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

Constraints

All values in input are integers.

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

a_i is 0 or 1.

Input

Input is given from Standard Input in the following format:

N
a_1 a_2 ... a_N

Output

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

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

M
b_1 b_2 ... b_M

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

Sample Input 1

3
1 0 0

Sample Output 1

1
1

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

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

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

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

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

Sample Input 2

5
0 0 0 0 0

Sample Output 2

0

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



Sample input:
3
1 0 0


Sample output:
1
1

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

n=ii()
arr=limii()
cnt=0
ans=[]

for i in range(n,0,-1):
    temp=0
    for j in range(1,n//i +1):
        temp+=arr[j*i -1]
    #print(temp)
    temp-=arr[i-1]
    temp%=2
    
    if temp!=arr[i-1]:

        ans.append(i)
        cnt+=1


print(cnt)
print(*list(reversed(ans)))

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

n=ii()
arr=limii()
cnt=0
ans=[]

for i in range(n,0,-1):
    temp=0
    for j in range(1,n//i +1):
        temp+=arr[j*i -1]
    #print(temp)
    temp%=2
    
    if temp==arr[i-1]:
        if temp==1:
            ans.append(i)
            cnt+=1

    else:
        if temp==0:
            ans.append(i)
            cnt+=1

print(cnt)
print(*list(reversed(ans)))

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

n=ii()
arr=limii()
cnt=0
ans=[]

for i in range(n,0,-1):
    temp=0
    for j in range(1,n//i +1):
        temp+=arr[j*i -1]
    #print(temp)
    temp%=2
    
    if temp==arr[i-1]:
        if temp==0:
            ans.append(i)
            cnt+=1

    else:
        if temp==1:
            ans.append(i)
            cnt+=1

print(cnt)
print(*list(reversed(ans)))

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

n=ii()
arr=limii()
cnt=0
ans=[]

for i in range(n,0,-1):
    temp=0
    for j in range(1,n//i +1):
        temp+=arr[j*i -1]
    #print(temp)
    temp%=2
    
    if temp==arr[i-1]:
        if temp==1:
            ans.append(i)
            cnt+=1

    else:
        if temp==1:
            ans.append(i)
            cnt+=1

print(cnt)
print(*list(reversed(ans)))

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

n=ii()
arr=limii()
cnt=0
ans=[]

for i in range(n,0,-1):
    temp=0
    for j in range(1,n//i +1):
        temp+=arr[j*i -1]
    print(temp)
    temp%=2
    
    if temp==arr[i-1]:
        if temp==1:
            ans.append(i)
            cnt+=1

    else:
        if temp==1:
            ans.append(i)
            cnt+=1

print(cnt)
print(*list(reversed(ans)))

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

n=ii()
arr=limii()
cnt=0
ans=[]

for i in range(n,0,-1):
    temp=0
    for j in range(1,n//i +1):
        temp+=arr[j*i-1]
    #print(temp)
    temp%=2
    
    if temp==arr[i-1]:
        pass
    else:
        if temp==1:
            ans.append(i)
            cnt+=1

print(cnt)
print(*list(reversed(ans)))

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

n=ii()
arr=limii()
cnt=0
ans=[]

for i in range(n,0,-1):
    temp=0
    for j in range(1,n//i +1):
        temp+=arr[j*i-1]
    #print(temp)
    temp%=2
    
    if temp==arr[i-1]:
        
        if temp==1:
            ans.append(i)
            cnt+=1
    else:
        if temp==1:
            ans.append(i)
            cnt+=1

print(cnt)
print(*list(reversed(ans)))

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

n=ii()
arr=limii()
cnt=0
ans=[]

for i in range(n,0,-1):
    temp=0
    for j in range(1,n//i +1):
        temp+=arr[j*i-1]
    print(temp)
    temp%=2
    
    if temp==arr[i-1]:
        
        if temp==1:
            ans.append(i)
            cnt+=1
    else:
        if temp==1:
            ans.append(i)
            cnt+=1

print(cnt)
print(*list(reversed(ans)))

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

n=ii()
arr=limii()
cnt=0
ans=[]

for i in range(n,0,-1):
    temp=0
    for j in range(1,n//i +1):
        temp+=arr[j*i-1]
    temp%=2
    if temp==arr[i-1]:
        
        if temp==1:
            ans.append(i)
            cnt+=1
    else:
        if temp==1:
            pass
        else:
            ans.append(i)
            cnt+=1
print(cnt)
print(*list(reversed(ans)))

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

n=ii()
arr=limii()
cnt=0
ans=[]

for i in range(n,0,-1):
    temp=0
    for j in range(1,n//i +1):
        temp+=arr[j*i-1]
    temp%=2
    if temp==arr[i-1]:
        ans.append(temp)
        if temp==1:
            cnt+=1
    else:
        if temp==1:
            ans.append(0)
        else:
            ans.append(1)
            cnt+=1
print(cnt)
print(*list(reversed(ans)))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
p = 1
q = []
ans = 0
for i in range(n):
    if a[i] == 1:
        q.append(i+1) 
        ans += 1
    elif a[i] == 0:
        continue
    else:
        p = -1
if p == -1:
    print(-1)
else:
    print(ans)
    if ans != 0:
        for i in range(len(q)):
            print(q[i],end=' ')

Submission status: Wrong Answer

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

for i in range(1, N//2 + 1)[::-1]:
    wa = 0
    for j in range(2, N+1):
        if i * j > N:
            break
        wa += A[i*j]
    wa %= 2
    if A[i] == wa:
        A[i] = 0
    else:
        A[i] = 1


A = A[1:]
print(A.count(1))
for i, j in enumerate(A):
    if j == 1:
        print(i, end=' ')

Submission status: Wrong Answer

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

for i in range(N//2 + 1)[::-1]:
    wa = 0
    for j in range(2, N+1):
        if i * j > N:
            break
        wa += A[i*j]
    wa %= 2
    if A[i] == wa:
        A[i] = 0
    else:
        A[i] = 1


A = A[1:]
print(A.count(1))
for i in A:
    if i == 1:
        print(i, end=' ')

Submission status: Wrong Answer

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

for i in range(N//2 + 1)[::-1]:
    wa = 0
    for j in range(2, N+1):
        if i * j > N:
            break
        wa += A[i*j]
    wa %= 2
    if A[i] != wa:
        A[i] = (A[i] + 1) % 2

A = A[1:]

print(A.count(1))
for i in A:
    if i == 1:
        print(i, end=' ')

Submission status: Wrong Answer

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

for i in range(N//2 + 1)[::-1]:
    wa = 0
    for j in range(1, N+1):
        if i * j > N:
            break
        wa += A[i*j]
    wa %= 2
    A[i] = wa

A = A[1:]

print(A.count(1))
for i in A:
    if i == 1:
        print(i, end=' ')

Submission status: Wrong Answer

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

dev=[]
for i in range(N):
    n=i+1
    temp=[]
    for j in range(1,round(n**0.5)+1):
        if n%j==0:
            temp.append(j)
        if n//j!=j and n//j!=1:
            temp.append(n//j)
    dev.append(temp)

ans=[0 for _ in range(N)]
for k in range(N):
    m=N-k
    if a[m-1]!=ans[m-1]%2:
        for d in dev[m-1]:
            ans[d-1]+=1
print(sum(ans))
b=[]
for l in range(N):
    if ans[l]%2!=0:
        b.append(l+1)
for B in b:
    print(B,end=" ")

Submission status: Wrong Answer

Solution code:
# import sys
# sys.setrecursionlimit(10**5)
# from collections import defaultdict

geta = lambda fn: list(map(fn, input().split()))
gete = lambda fn: fn(input())

N = gete(int)
a = geta(int)

b = [-1 if i * i <= N else a[i - 1] for i in range(N + 1)]

i = N + 1
while i > 1:
    i -= 1
    if b[i] != -1:
        continue

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

bm = list(filter(lambda i: b[i] == 1, range(1, N + 1)))

print(len(bm))
if len(bm) > 0:
    print(*bm, sep=" ")

Submission status: Wrong Answer

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

ans=[]
for i in range(n-1,-1,-1):
    if i+1>n//2:
        L[i]=a[i]
    else:
        t=n//(i+1)
        el=0
        for j in range(1,t+1):
            el += a[(i+1)*j-1]
        L[i]=el%2
    if L[i]==1:
        ans.append(str(i+1))

print(len(ans))
if len(ans)>0:
    print(' '.join(ans))

Submission status: Wrong Answer

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

cnt=0
for i in range(N-1,-1,-1):
  if 2*i+1>N-1:
    b[i]=a[i]
  else:
    summ = sum(a[2*i+1::i+1])
    if summ%2==0:
      b[i] = a[i]
    else:
      b[i] = 1-a[i]
    #print(i,summ,b[i])
    
ans=[]
print(sum(b))
for i,num in enumerate(b):
  if num==1:
    ans.append(i+1)

print(*ans)

Submission status: Wrong Answer

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

for i in range(N-1,-1,-1):
  if 2*(i+1)>N:
    b[i]=a[i]
  else:
    summ = sum(a[2*i+1::i+1])
    if summ%2==0:
      b[i] = a[i]
    else:
      b[i] = 1-a[i]
    #print(i,summ,b[i])
    
ans=[]
for num in b:
  if num!=0:
    ans.append(num)
print(len(ans))
print(*ans)

Submission status: Wrong Answer

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

for i in range(N-1,-1,-1):
  if 2*(i+1)>N:
    b[i]=a[i]
  else:
    summ = sum(a[2*i+1::i+1])
    if a[i]==0:
      b[i] = summ%2  
    else:
      b[i] = 1-summ%2
    
ans=[]
for num in b:
  if num!=0:
    ans.append(num)
print(len(ans))
print(*ans)

Submission status: Wrong Answer

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

for i in range(N-1,-1,-1):
  if 2*(i+1)>N:
    b[i]=a[i]
  else:
    summ = sum(a[2*i+1::i+1])
    if summ%2==0:
      b[i]= a[i]
    else:
      b[i] = 1-a[i]
    #print(i,summ,b)
    
ans=[]
for num in b:
  if num!=0:
    ans.append(num)
print(len(ans))
print(*ans)

Submission status: Wrong Answer

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

for i in range(N-1,-1,-1):
  if 2*(i+1)>N:
    b[i]=a[i]
  else:
    summ = sum(a[2*i+1::i+1])
    if summ%2==0:
      b[i]= 1
    else:
      b[i] = 0
#print(b)
    
ans=[]
for num in b:
  if num!=0:
    ans.append(num)
print(len(ans))
print(*ans)

Submission status: Wrong Answer

Solution code:
from math import floor

def calc(x):
  ans=[]
  p=ceil(x**0.5)
  for i in range(1,p+1):
    if x%i==0:
      ans.append(i)
  return ans  

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

for i in range(N,0,-1):
  if 2*i>N:
    b[i-1]=a[i-1]
  else:
    if b[i-1+i]%2==0:
      b[i-1]=a[i-1]
    else:
      b[i-1]=1-a[i-1]
    
ans=[]
for num in b:
  if num!=0:
    ans.append(num)
print(len(ans))
print(*ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
*A, = map(int, input().split())
b = [0] * N
for i in range(N-1, -1, -1):
   chk = sum(b[i:N:i+1])
   if chk ^ A[i]:
       b[i] = 1

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

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    A = [-1] + [int(_) for _ in input().split()]
    haco = [0] * (N+1)
    m = 0

    for i in range(1, N+1)[::-1]:
        max_j = N // i
        cc = 0
        for j in range(1, max_j+1):
            cc += haco[i*j]
        cc -= haco[i]
        cc %= 2
        if cc == A[i]: haco[i*j] = 0
        else:
            haco[i] = 1
            m += 1
    print(m)
    if m:
        for i in range(1, N+1):
            if haco[i]: print(i, end=' ')
        print('')
    return

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10000000)
input=sys.stdin.readline

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

b=[0]*n

for i in range(n-1,-1,-1):
    if not sum(b[i+1:n:i+1]) %2 and a[i]==1:
        b[i] = 1 

print(sum(b))
print(" ".join([str(k+1)  for k,v in enumerate(b)  if v== 1]))

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10000000)
input=sys.stdin.readline

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

b=[0]*n

for i in range(n-1,-1,-1):
    if not sum(b[i+1:n:i+1]) %2 and a[i]==1:
        b[i] = 1 

print(sum(b))
print(" ".join([str(i)  for i in b if i== 1]))

Submission status: Wrong Answer

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

b=[0]*n

for i in range(n-1,-1,-1):
    if not sum(b[i:n:i+1]) %2 and a[i]==1:
        b[i] = 1 

print(sum(b))
print(" ".join([str(i)  for i in b if i== 1]))

Submission status: Wrong Answer

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

b=[0]*n

for i in range(n-1,-1,-1):
    if not sum(b[i+1:n:i+1]) %2 and a[i]==1:
        b[i] = 1 

print(sum(b))
print(" ".join([str(i)  for i in b if i== 1]))

Submission status: Wrong Answer

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

    B = [0] * n
    for i in range(n - 1, -1, -1):
        s = 0
        for j in range(n // (i + 1)):
            s += B[i * (j + 1)]

        if s % 2 != A[i]:
            B[i] = 1

    print(B.count(1))

    if B.count(1) != 0:
        print(' '.join([str(i + 1) for i in range(n) if B[i] == 1]))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
res = [0] * N
for i in range(N, 0, -1):
    tmp = 0
    for j in range(i * (N // i), i, -i):
        tmp += res[j - 1]
    if A[i - 1] != (tmp + res[i - 1]) % 2:
        res[i - 1] ^= 1
print(sum(A))
ans = [i + 1 for i, v in enumerate(res) if v == 1]
if ans:
    print(*ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
l=[0]*n
for i in reversed(range(1,n+1)):
    x=0
    if n//i>1:
        for j in range(1,n//i):
            x+=l[(j+1)*i-1]
        if x%2==a[i-1]:
            l[i-1]=0
        else:
            l[i-1]=1
    else:
        l[i-1]=a[i-1]
m=l.count(1)
print(m)
if m>0:
    for i in range(m):
        print(1,end="")

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
l=[0]*n
for i in reversed(range(1,n+1)):
    x=0
    if n//i>1:
        for j in range(1,n//i):
            x+=l[(j+1)*i-1]
        if x%2==a[i-1]:
            l[i-1]=0
        else:
            l[i-1]=1
    else:
        l[i-1]=a[i-1]
m=l.count(1)
print(m)
if m>0:
    for i in range(m):
        print(1,end=" ")

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
l=[0]*n
for i in reversed(range(1,n+1)):
    x=0
    if n//i>1:
        for j in range(1,n//i):
            x+=l[(j+1)*i-1]
        if x%2==a[i-1]:
            l[i-1]=0
        else:
            l[i-1]=1
    else:
        l[i-1]=a[i-1]
m=l.count(1)
print(m)
if m>0:
    for i in range(m):
        print(1)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
l=[0]*n
for i in reversed(range(1,n+1)):
    x=0
    if n//i>1:
        for j in range(1,n//i):
            x+=a[(j+1)*i-1]
        if x%2==a[i-1]:
            l[i-1]=0
        else:
            l[i-1]=1
    else:
        l[i-1]=a[i-1]
m=l.count(1)
print(m)
if m>0:
    for i in range(m):
        print(1)

Submission status: Wrong Answer

Solution code:
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n=int(input())
    A=[int(_) for _ in input().split()]
    B=[0]*n
    for i in range(n-1,-1,-1):
        x=2*(i+1)
        other=0
        while x<=n:
            other+=B[x-1]
            x+=x
        if other%2==A[i]:
            B[i]=0
        else:
            B[i]=1
    print(sum(B))
    print(*[int(i+1) for i,x in enumerate(B) if x==1])

if __name__=='__main__':
    main()

Submission status: Wrong Answer

Solution code:
n = int(input())
l = list(map(int,input().split()))
k = [0 for i in range(n)]
t = []
for i in range(n-1,-1,-1):
  a = l[i]
  if a!=k[i]:
    t.append(i+1)
    for j in range(i,int((i+1)**0.5-1),-1):
      if (i+1)%(j+1)==0:
        k[j] += 1
        k[(i+1)//(j+1)-1] += 1
        k[j] %= 2
        k[(i+1)//(j+1)-1] %= 2
if len(t)==0:
  print(0)
else:
  print(len(t))
  print(*t)

Submission status: Wrong Answer

Solution code:
N = int(input())
*A, = map(int, input().split())
upto = int(N ** 0.5)
M = 0
ans = []
for i in range(upto):
    chk = sum(A[::i+1]) % 2
    if chk == A[i] and chk != 0:
        M += 1
        ans.append(i+1)
print(M)
print(*ans)

Submission status: Wrong Answer

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

c = [ 0 ] * N
for i in range( N , 0, -1 ):
  c[ i - 1 ] = a[ i - 1 ]
  for j in range( 2, N // i + 1 ):
    c[ i - 1 ] += a[ i * j - 1 ]

m = 0
b = ""
for i in range( N ):
  if c[i] > 0:
    m += 1
    b += str( i + 1 ) + " "
print( m )
print( b[:-1] )

Submission status: Wrong Answer

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

c = [ 0 ] * N
for i in range( N , 0, -1 ):
  c[ i - 1 ] = a[ i - 1 ]
  for j in range( 2, N // i + 1 ):
    c[ i - 1 ] -= a[ i * j - 1 ]

m = 0
b = ""
for i in range( N ):
  if c[i] > 0:
    m += 1
    b += str( i + 1 ) + " "
print( m )
print( b[:-1] )

Submission status: Wrong Answer

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def main():
    N = int(readline())
    A = [0] + [int(i) for i in readline().split()]
    table = [0 for _ in range(N+1)]
    for i in range(N, 0, -1):
        table[i] = sum(table[::i])&A[i]

    print(sum(table))
    for i in range(N):
        if table[i+1]:
            print(i+1, end=' ')
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def main():
    N = int(readline())
    A = [0] + [int(i) for i in readline().split()]
    table = [0 for _ in range(N+1)]
    for i in range(N, 0, -1):
        table[i] = sum(table[::i])^A[i]

    print(sum(table))
    for i in range(N):
        if table[i+1]:
            print(i+1, end=' ')
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def main():
    N = int(readline())
    A = [0] + [int(i) for i in readline().split()]
    table = [0 for _ in range(N+1)]
    for i in range(N, 0, -1):
        table[i] = (sum(table[::i])+A[i])%2

    print(sum(A))
    for i in range(N):
        if table[i+1]:
            print(i+1, end=' ')
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def main():
    N = int(readline())
    A = [0] + [int(i) for i in readline().split()]
    for i in range(N, 0, -1):
        A[i] = (sum(A[i+1::i])+A[i])%2

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