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 numpy as np
import math
import copy
import re
import sys
#sys.exit(0)

inf = float("inf")
prime = 1

def check_print(check_flag, text, end="\n"):
  if check_flag:
    print(text, end=end)

def c2i(x):
    if str.isdecimal(x):
        return int(x)
    else:
        return x

def cout(*args):
  arglist = []
  for arg in args:
    if hasattr(arg, "__iter__"):
      arglist.extend(arg)
    else:
      arglist.append(arg)
      
  arglist = list(map(str, arglist))
  print(" ".join(arglist))
  
def count2(num):
  count=0
  while num%2==0:
    num/=2
    count+=1
  return count

def ketasum(num):
  nums = [int(s) for s in str(num)]
  return sum(nums)

#math
def gcd(a, b): #最大公約数
  while b:
    a, b = b, a % b
  return a

def lcm(a, b): #最小公倍数
  return a * b // gcd (a, b)

def gcd3(lis): #最大公約数(3over)
  ans = lis[0]
  for li in lis:
    ans = gcd(ans,li)

def lcm3(lis): #最小公倍数(3over)
  ans = lis[0]
  for li in lis:
    ans = lcm(ans,li)

def divisor(n): #nの約数を全て求める
  i = 1
  table = []
  while i * i <= n:
    if n%i == 0:
      table.append(i)
      table.append(n//i)
    i += 1
  table = list(set(table))
  return table

def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n /= i
      table.append(i)
    i += 1
  if n > 1:
    table.append(n)
  return table

def is_prime(n):
  for i in range(2, n + 1):
    if i * i > n:
      break
    if n % i == 0:
      return False
  return n != 1

#input stock
"""
n = int(input())

#list
a = map(int, input().split())
a,b = map(int, input().split())

#縦1dim-list
a = [int(input()) for i in range(n)]

d=[]
for i in range(n):
  d[i]=int(input())

#2dim-list
a = [list(map(int, input().split())) for i in range(n)]

s = input()
ss =  [int(si) for si in s]
"""

#processing stock
"""
a = sorted(a)
a = sorted(a, reverse=True)

"""

#regex
"""
pattern = ""
result = re.search(pattern, s)

result = re.fullmatch(pattern, s)

result = re.finditer(pattern, s)
for res in result:
    print res.group()   # 1回目: ca      2回目: ca   
    print res.start()   # 1回目: 0       2回目: 6      
    print res.end()     # 1回目: 2       2回目: 8      
    print res.span()    # 1回目: (0, 2)  2回目: (6, 8)
"""


#math
"""
#切り捨て
math.floor()
# 切り上げ
math.ceil()
"""

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

for i in reversed(range(n)):
  if sum(ret[::i+1])%2 != a[i]:
    ret[i] = 1

cout(ret)

Submission status: Wrong Answer

Solution code:
#######################################
import numpy as np
import math
import copy
import re
import sys
#sys.exit(0)

inf = float("inf")
prime = 1

def check_print(check_flag, text, end="\n"):
  if check_flag:
    print(text, end=end)

def c2i(x):
    if str.isdecimal(x):
        return int(x)
    else:
        return x

def cout(*args):
  arglist = []
  for arg in args:
    if hasattr(arg, "__iter__"):
      arglist.extend(arg)
    else:
      arglist.append(arg)
      
  arglist = list(map(str, arglist))
  print(" ".join(arglist))
  
def count2(num):
  count=0
  while num%2==0:
    num/=2
    count+=1
  return count

def ketasum(num):
  nums = [int(s) for s in str(num)]
  return sum(nums)

#math
def gcd(a, b): #最大公約数
  while b:
    a, b = b, a % b
  return a

def lcm(a, b): #最小公倍数
  return a * b // gcd (a, b)

def gcd3(lis): #最大公約数(3over)
  ans = lis[0]
  for li in lis:
    ans = gcd(ans,li)

def lcm3(lis): #最小公倍数(3over)
  ans = lis[0]
  for li in lis:
    ans = lcm(ans,li)

def divisor(n): #nの約数を全て求める
  i = 1
  table = []
  while i * i <= n:
    if n%i == 0:
      table.append(i)
      table.append(n//i)
    i += 1
  table = list(set(table))
  return table

def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n /= i
      table.append(i)
    i += 1
  if n > 1:
    table.append(n)
  return table

def is_prime(n):
  for i in range(2, n + 1):
    if i * i > n:
      break
    if n % i == 0:
      return False
  return n != 1

#input stock
"""
n = int(input())

#list
a = map(int, input().split())
a,b = map(int, input().split())

#縦1dim-list
a = [int(input()) for i in range(n)]

d=[]
for i in range(n):
  d[i]=int(input())

#2dim-list
a = [list(map(int, input().split())) for i in range(n)]

s = input()
ss =  [int(si) for si in s]
"""

#processing stock
"""
a = sorted(a)
a = sorted(a, reverse=True)

"""

#regex
"""
pattern = ""
result = re.search(pattern, s)

result = re.fullmatch(pattern, s)

result = re.finditer(pattern, s)
for res in result:
    print res.group()   # 1回目: ca      2回目: ca   
    print res.start()   # 1回目: 0       2回目: 6      
    print res.end()     # 1回目: 2       2回目: 8      
    print res.span()    # 1回目: (0, 2)  2回目: (6, 8)
"""


#math
"""
#切り捨て
math.floor()
# 切り上げ
math.ceil()
"""

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

for i in reversed(range(n)):
  idx = [j for j in range(n) if (j+1)%(i+1)==0]
  idx = np.array(idx)

  if sum(ret[idx])%2 != a[i]:
    ret[i] = 1

cout(ret)

Submission status: Wrong Answer

Solution code:
#######################################
import numpy as np
import math
import copy
import re
import sys
#sys.exit(0)

inf = float("inf")
prime = 1

def check_print(check_flag, text, end="\n"):
  if check_flag:
    print(text, end=end)

def c2i(x):
    if str.isdecimal(x):
        return int(x)
    else:
        return x

def cout(*args):
  arglist = []
  for arg in args:
    if hasattr(arg, "__iter__"):
      arglist.extend(arg)
    else:
      arglist.append(arg)
      
  arglist = list(map(str, arglist))
  print(" ".join(arglist))
  
def count2(num):
  count=0
  while num%2==0:
    num/=2
    count+=1
  return count

def ketasum(num):
  nums = [int(s) for s in str(num)]
  return sum(nums)

#math
def gcd(a, b): #最大公約数
  while b:
    a, b = b, a % b
  return a

def lcm(a, b): #最小公倍数
  return a * b // gcd (a, b)

def gcd3(lis): #最大公約数(3over)
  ans = lis[0]
  for li in lis:
    ans = gcd(ans,li)

def lcm3(lis): #最小公倍数(3over)
  ans = lis[0]
  for li in lis:
    ans = lcm(ans,li)

def divisor(n): #nの約数を全て求める
  i = 1
  table = []
  while i * i <= n:
    if n%i == 0:
      table.append(i)
      table.append(n//i)
    i += 1
  table = list(set(table))
  return table

def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n /= i
      table.append(i)
    i += 1
  if n > 1:
    table.append(n)
  return table

def is_prime(n):
  for i in range(2, n + 1):
    if i * i > n:
      break
    if n % i == 0:
      return False
  return n != 1

#input stock
"""
n = int(input())

#list
a = map(int, input().split())
a,b = map(int, input().split())

#縦1dim-list
a = [int(input()) for i in range(n)]

d=[]
for i in range(n):
  d[i]=int(input())

#2dim-list
a = [list(map(int, input().split())) for i in range(n)]

s = input()
ss =  [int(si) for si in s]
"""

#processing stock
"""
a = sorted(a)
a = sorted(a, reverse=True)

"""

#regex
"""
pattern = ""
result = re.search(pattern, s)

result = re.fullmatch(pattern, s)

result = re.finditer(pattern, s)
for res in result:
    print res.group()   # 1回目: ca      2回目: ca   
    print res.start()   # 1回目: 0       2回目: 6      
    print res.end()     # 1回目: 2       2回目: 8      
    print res.span()    # 1回目: (0, 2)  2回目: (6, 8)
"""


#math
"""
#切り捨て
math.floor()
# 切り上げ
math.ceil()
"""

#######################################
n = int(input())
a = np.array(list(map(int, input().split())))
ret = np.array([-1]*n)

mid = math.ceil(n/2)
ret[mid-1:] = a[mid-1:]

for i in reversed(range(0,mid)):
  idx = [j for j in range(n) if (j+1)%(i+1)==0]
  idx2 = [j for j in range(n) if (j+1)%(i+1)==0 and ret[j]==-1]
  idx3 = [j for j in range(n) if (j+1)%(i+1)==0 and ret[j]!=-1]
  idx = np.array(idx)
  idx2 = np.array(idx2)
  idx3 = np.array(idx3)

  if len(idx)==1:
    ret[i] = a[i]
  elif len(idx2)==1:
    ret[i] = (sum(a[idx]) - sum(a[idx3]))%2
  
cout(ret)

Submission status: Wrong Answer

Solution code:
#######################################
import numpy as np
import math
import copy
import re
import sys
#sys.exit(0)

inf = float("inf")
prime = 1

def check_print(check_flag, text, end="\n"):
  if check_flag:
    print(text, end=end)

def c2i(x):
    if str.isdecimal(x):
        return int(x)
    else:
        return x

def cout(*args):
  arglist = []
  for arg in args:
    if hasattr(arg, "__iter__"):
      arglist.extend(arg)
    else:
      arglist.append(arg)
      
  arglist = list(map(str, arglist))
  print(" ".join(arglist))
  
def count2(num):
  count=0
  while num%2==0:
    num/=2
    count+=1
  return count

def ketasum(num):
  nums = [int(s) for s in str(num)]
  return sum(nums)

#math
def gcd(a, b): #最大公約数
  while b:
    a, b = b, a % b
  return a

def lcm(a, b): #最小公倍数
  return a * b // gcd (a, b)

def gcd3(lis): #最大公約数(3over)
  ans = lis[0]
  for li in lis:
    ans = gcd(ans,li)

def lcm3(lis): #最小公倍数(3over)
  ans = lis[0]
  for li in lis:
    ans = lcm(ans,li)

def divisor(n): #nの約数を全て求める
  i = 1
  table = []
  while i * i <= n:
    if n%i == 0:
      table.append(i)
      table.append(n//i)
    i += 1
  table = list(set(table))
  return table

def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n /= i
      table.append(i)
    i += 1
  if n > 1:
    table.append(n)
  return table

def is_prime(n):
  for i in range(2, n + 1):
    if i * i > n:
      break
    if n % i == 0:
      return False
  return n != 1

#input stock
"""
n = int(input())

#list
a = map(int, input().split())
a,b = map(int, input().split())

#縦1dim-list
a = [int(input()) for i in range(n)]

d=[]
for i in range(n):
  d[i]=int(input())

#2dim-list
a = [list(map(int, input().split())) for i in range(n)]

s = input()
ss =  [int(si) for si in s]
"""

#processing stock
"""
a = sorted(a)
a = sorted(a, reverse=True)

"""

#regex
"""
pattern = ""
result = re.search(pattern, s)

result = re.fullmatch(pattern, s)

result = re.finditer(pattern, s)
for res in result:
    print res.group()   # 1回目: ca      2回目: ca   
    print res.start()   # 1回目: 0       2回目: 6      
    print res.end()     # 1回目: 2       2回目: 8      
    print res.span()    # 1回目: (0, 2)  2回目: (6, 8)
"""


#math
"""
#切り捨て
math.floor()
# 切り上げ
math.ceil()
"""

#######################################
n = int(input())
a = np.array(list(map(int, input().split())))
ret = np.array([-1]*n)

mid = int(n/2)

for i in range(n):
  i_idx, i_val = n-i-1, n-i
  idx = [j for j in range(n) if (j+1)%i_val==0]
  idx2 = [j for j in range(n) if (j+1)%i_val==0 and ret[j]==-1]
  idx3 = [j for j in range(n) if (j+1)%i_val==0 and ret[j]!=-1]
  idx = np.array(idx)
  idx2 = np.array(idx2)
  idx3 = np.array(idx3)

  if len(idx)==1:
    ret[i_idx] = a[i_idx]
  elif len(idx2)==1:
    ret[i_idx] = (sum(a[idx]) - sum(a[idx3]))%2
  
cout(ret)

Submission status: Wrong Answer

Solution code:
from collections import OrderedDict
N = int(input())
a = list(map(int, str(input()).split()))

box = OrderedDict(zip(range(N, 0, -1), [0] * N))
print(box)
output = list()
count = 0
for i in box:
    mul = N // i
    total_ball = 0
    for m in range(1,mul+1):
        total_ball += box[m * i]
    if (a[i-1] == 1 and total_ball % 2 == 0) or (a[i-1] == 0 and total_ball % 2 == 1) :
        box[i] = 1
        count += 1
        output.append(str(i))
    else:
        pass

if len(output) != 0:
    print(count)
    print(' '.join(output))
else:
    print(0)

Submission status: Wrong Answer

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

box = dict(zip(range(N, 0, -1), [0] * N))
output = list()
count = 0
for i in box:
    mul = N // i
    total_ball = 0
    for m in range(1,mul+1):
        total_ball += box[m * i]
    if (a[i-1] == 1 and total_ball % 2 == 0) or (a[i-1] == 0 and total_ball % 2 == 1) :
        box[i] = 1
        count += 1
        output.append(str(i))
    else:
        pass

if len(output) != 0:
    print(count)
    print(' '.join(output))
else:
    print(0)

Submission status: Wrong Answer

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

box = dict(zip(range(N, 0, -1), [0] * N))
output = list()
for i in box:
    mul = N // i
    total_ball = 0
    for m in range(1,mul+1):
        total_ball += box[m * i]
    if (a[i-1] == 1 and total_ball % 2 == 0) or (a[i-1] == 0 and total_ball % 2 == 1) :
        box[i] = 1
        output.append(str(i))
    else:
        pass

if len(output) != 0:
    print(' '.join(output))
else:
    print(0)

Submission status: Wrong Answer

Solution code:
def main(n, a):
    box = [0 for _ in range(n)]
    for i in range(n, 0, -1):
        if i > n // 2:
            factors = []
        else:
            factors = [x for x in range(i + 1, n + 1) if x % i == 0]

        if a[i - 1] != sum([a[i - 1]] + factors) % 2:
            box[i - 1] = 1

    print(n)
    print(" ".join(map(str, box)))


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

Submission status: Wrong Answer

Solution code:
def main(n, a):
    box = [0 for _ in range(n)]
    for i in range(n, 0, -1):
        if i > n // 2:
            factors = []
        else:
            factors = [x for x in range(i + 1, n + 1) if x % i == 0]
        if a[i - 1] == 0:
            if sum([a[i - 1]] + factors) % 2 == 1:
                box[i - 1] = 1
        else:
            if sum([a[i - 1]] + factors) % 2 == 0:
                box[i - 1] = 1
    print(sum(box))
    print(' '.join(map(str, box)))


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

Submission status: Wrong Answer

Solution code:
import sys
import copy
def input():
    return sys.stdin.readline()
ans = []
tmp = []
n = int(input())
a = [int(i) for i in input().split()]

for i in range(n-1, -1, -1):
  if i > n/2:
    if a[i] ==1:
      ans.append(i)
  else:
    for j in range(1,n+1,i+1):
      tmp.append(j)
    tmp_set = set(tmp)
    ans_set = set(ans)
    set_ = tmp_set & ans_set
    tmp.clear()
    eo = (len(set_)) % 2
    if (a[i]) ^ eo == 1:
      ans.append(i)
print(len(ans))
for i in reversed(ans):
  print(i+1,end=' ')

Submission status: Wrong Answer

Solution code:
def D_PreparingBoxes():
    N = int(input())
    a = list(map(int, input().split()))
    b = [0] * N
    for x in range(N):
        index = N - x -1
        if (sum(b) % 2) != a[index]:
            b[index] = 1
    print(sum(b))
    for x in range(N):
        if b[x]:
            print(x+1, end=" ")

if __name__ == "__main__":
    D_PreparingBoxes()

Submission status: Wrong Answer

Solution code:
def D_PreparingBoxes():
    N = int(input())
    a = list(map(int, input().split()))
    b = [0] * N
    for x in range(N):
        num = 0
        index = N - x -1
        for y in range(x+1):
            #print(x, y, index+(index + 1) * y)
            if index+(index + 1) * y >= N:
                break
            else:
                num += b[index+(index + 1) * y] % 2
        if num != a[index]:
            b[index] = 1
    print(sum(b))
    for x in range(N):
        if b[x]:
            print(x+1, end=" ")

if __name__ == "__main__":
    D_PreparingBoxes()

Submission status: Wrong Answer

Solution code:
N=int(input())
a=input().split()
for i in range(0,N):
    a[i]=int(a[i])
b=a
for i in range(0,N):
    k=N//N-i
    l=0
    if k>=2:
        for j in range(2,k+1):
            l=(l+b[j*(N-i)-1])%2
            b[N-i-1]=(a[N-i-1]-l)%2
    else:
        b[N-i-1]=a[N-i-1]
c=""
M=0
for i in range(0,N):
    if b[i]==1:
        M+=1
        c=c+str(i+1)+" "
print(M)
if c!="":
    print(c)

Submission status: Wrong Answer

Solution code:
N=int(input())
a=input().split()
for i in range(0,N):
    a[i]=int(a[i])
b=a
for i in range(0,N):
    k=N//N-i
    l=0
    for j in range(2,k+1):
        l=(l+b[j*(N-i)-1])%2
        b[N-i-1]=(a[N-i-1]-l)%2
c=""
M=0
for i in range(0,N):
    if b[i]==1:
        M+=1
        c=c+str(i+1)+" "
print(M)
if c!="":
    print(c)

Submission status: Wrong Answer

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

filled = [0 for _ in range(n)]
ans = []
for i in range(n-1, -1, -1):
  if sum(filled[i:][::i+1]) % 2 != A[i]:
    filled[i] = 1
    ans.append(i+1)
    print(len(ans))
    print(' '.join(map(str, ans)))

Submission status: Wrong Answer

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

    filled = [0 for _ in range(n)]
    for i in range(n-1, -1, -1):
        if sum(filled[i:][::i+1]) != A[i]:
            filled[i] = 1

    filled = [i+1 for i in range(n) if filled[i] == 1]
    return len(filled), filled


if __name__ == '__main__':
    m, output = main()
    print(str(m))
    if m > 0:
        print(' '.join(map(str, output)))

Submission status: Wrong Answer

Solution code:
import math

N = int(input())
n = math.ceil(N/2)

a = [0] + list(map(int, input().split()))
b = [0] *(N-n+N%2) + a[n:]
ans = a[n:].count(1)

for i in range(n, 0, -1):
    mod = sum(b[i::i]) % 2
    if mod == a[i]:
        pass
    else:
        b[i] = 1
        ans += 1
    
print(ans)
for idx, n in enumerate(b):
    if n:
        print(idx, '', end='')

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):
    B[i] = (sum(B[i::(i+1)])%2+A[i])%2
print(sum(B))
print(*[i for i, b in enumerate(set(B)) if b == 1])

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int, input().split()))
boxes = [0 for _ in range(N)]
ans = []
for i in range(N):
    j = N-i
    count = sum([boxes[k] for k in range(j,N,j)])
#    k = j*2
#    while k<N+1:
#        if k in ans:
#            count += 1
#        k += j
    if count%2 != a[j-1]:
        ans.append(j)
print(len(ans))
ans = [str(x) for x in ans]
ans = ' '.join(ans)
print(ans)

Submission status: Wrong Answer

Solution code:
import math

N=int(input())
alist=[0]+list(map(int,input().split()))

blist=[0]*(N+1)
for i in reversed(range(1,N+1)):
  blist[i]^=alist[i]
  if i != 1:
    blist[1]^=blist[i]          
  for j in range(2,int(math.sqrt(i))+1):
    if i%j==0:
      blist[i//j]^=blist[i]
      if i//j != j:
        blist[j]^=blist[i]
  
#print(blist)
answer=sum(blist)
print(answer)
if answer>0:
  print(" ".join(["1"]*answer))

Submission status: Wrong Answer

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

blist=[0]*N
for i in range(N):
  j=1
  while (i+1)*j<=N:
    blist[i*j]+=alist[i*j]
    blist[i*j]%=2
    j+=1
    
#print(blist)
answer=sum(blist)
print(answer)
if answer>0:
  print(" ".join(["1"]*answer))

Submission status: Wrong Answer

Solution code:
N = int(input())
a = [int(i) for i in input().split()]
b = [0]*N
c = []
m = 0

for i in range(N-1,N//2,-1):
  if a[i] == 1:
    b[i] = 1
    c.append(i+1)
    m += 1
for i in range(N//2,-1,-1):
  sum_b = 0
  j = (i+1)*2
  while j <= N:
    sum_b += b[j-1]
    j += i+1
  if sum_b%2 != a[i]:
    c.append(i+1)
    m += 1

print(m)
print(" ".join(map(str,c)))

Submission status: Wrong Answer

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

for i in range(N-1,N//2,-1):
  if a[i] == 1:
    b.append(i+1)
    m += 1
for i in range(N//2,-1,-1):
  sum_b = 0
  j = (i+1)*2
  while j <= N:
    sum_b += a[j-1]
    j += i+1
  if sum_b%2 != a[i]:
    b.append(i+1)
    m += 1

print(m)
print(" ".join(map(str,b)))

Submission status: Wrong Answer

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

for i in range(N-1,N//2,-1):
  if a[i] == 1:
    b.append(i+1)
    m += 1
for i in range(N//2,-1,-1):
  sum_b = 0
  j = (i+1)*2
  while j <= N:
    sum_b += a[j-1]%2
    j += i+1
  if sum_b%2 != a[i]:
    b.append(i+1)
    m += 1

print(m)
print(" ".join(map(str,b)))

Submission status: Wrong Answer

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

for i in range(N-1,N//2-1,-1):
  if a[i] == 1:
    b.append(i+1)
    m += 1
for i in range(N//2-1,-1,-1):
  sum_b = 0
  j = (i+1)*2
  while j <= N:
    sum_b += a[j-1]%2
    j += i+1
  if sum_b%2 != a[i]:
    b.append(i+1)
    m += 1

print(m)
print(" ".join(map(str,b)))

Submission status: Wrong Answer

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

for i in range(N-1,N//2-1,-1):
  if a[i] == 1:
    b.append(i+1)
for i in range(N//2-1,-1,-1):
  sum_b = 0
  j = (i+1)*2
  while j <= N:
    sum_b += a[j-1]%2
    j += i+1
  if sum_b%2 != a[i]:
    b.append(i+1)
    m += 1

print(m)
print(" ".join(map(str,b)))

Submission status: Wrong Answer

Solution code:
N = int(input())
a = [int(i) for i in input().split()]
b = []
m = 0
  
for i in range(N-1,-1,-1):
  sum_b = 0
  j = (i+1)*2
  while j <= N:
    sum_b += a[j-1]%2
    j += i+1
  if sum_b%2 != a[i]:
    b.append(i+1)
    m += 1

print(m)
for i in b:
  print(i)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = [int(i) for i in input().split()]
b = []
m = 0
  
for i in range(N//2-1,-1,-1):
  sum_b = 0
  j = (i+1)*2
  while j <= N:
    sum_b += a[j-1]%2
    j += i+1
  if sum_b%2 != a[i]:
    b.append(i+1)
    m += 1

print(m)
for i in b:
  print(i)

Submission status: Wrong Answer

Solution code:
M = int(input())
a = list(map(int,input().split()))
a = [None]+a
b = [M-k for k in range(M)]
c = [0 for k in range(M+1)]
h = 0
for s in b:
	w = M // s
	wa = 0
	for k in range(w-1):
		wa += c[s*(k+2)]
	if wa % 2 == a[s]:
		c[s] = 0
	else:
		c[s] = 1
		h += 1
print(h)
for k in range(1,len(c)):
	if c[k] == 1:
		print(k, end="")

Submission status: Wrong Answer

Solution code:
M = int(input())
a = list(map(int,input().split()))
a = [None]+a
b = [M-k for k in range(M)]
c = [0 for k in range(M+1)]
for s in b:
	w = M // s
	wa = 0
	for k in range(w-1):
		wa += c[s*(k+2)]
	if wa % 2 == a[s]:
		c[s] = 0
	else:
		c[s] = 1
ans = ""
for k in range(1,len(c)):
	if c[k] == 1:
		ans = ans + str(k) + " "
print(ans)

Submission status: Wrong Answer

Solution code:
M = int(input())
a = list(map(int,input().split()))
a = [None]+a
b = [M-k for k in range(M)]
c = [0 for k in range(M+1)]
for s in b:
	w = M // s
	wa = 0
	for k in range(w):
		wa += c[s*(k+1)]
		if wa %2 == a[s]:
			c[s] = 0
		else:
			c[s] = 1
for k in range(1,len(c)):
	if c[k] == 1:
		print(k, end="")
		print(" ", end="")

Submission status: Wrong Answer

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

    for j in range(n):
        i = n - j -1
        if sum(x[i::i+1])%2 != a[i]:
            x[i] = 1
            b.add(i+1)
    cnt = len(b)

    if cnt == 0:
        print(0)
    else:
        print(cnt)
        print(*b)


#resolve()

Submission status: Wrong Answer

Solution code:

def resolve():
    n = int(input())
    a = list(map(int,input().split()))
    x = [0]*n

    for j in range(n):
        i = n - j -1
        if sum(x[i::i+1])%2 != a[i]:
            x[i] += 1
    if all(a[i] == sum(a[i::i+1])%2 for i in range(n)):
        print(sum(x))
#        for i in range(n):
#            if x[i] == 1: print(i+1,end=' ')
        index = [i + 1 for i,v in enumerate(x) if v == 1]
        if len(index) >0:
             print(*index)
    else:
        print('-1')
resolve()

Submission status: Wrong Answer

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

    for i in reversed(range(n)):
        if sum(x[i::i+1])%2 != a[i]:
            x[i] += 1
    if all(a[i] == sum(a[i::i+1])%2 for i in range(n)):
        print(sum(x))
#        for i in range(n):
#            if x[i] == 1: print(i+1,end=' ')
        index = [i + 1 for i,v in enumerate(x) if v == 1]
        if len(index) >0:
             print(*index)
    else:
        print('-1')
resolve()

Submission status: Wrong Answer

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

    for i in range(n):
        if sum(x[i::i+1])%2 != a[i]:
            x[i] += 1
    if all(a[i] == sum(a[i::i+1])%2 for i in range(n)):
        print(sum(x))
#        for i in range(n):
#            if x[i] == 1: print(i+1,end=' ')
        index = [i + 1 for i,v in enumerate(x) if v == 1]
        if len(index) >0:
             print(*index)
    else:
        print('-1')
resolve()

Submission status: Wrong Answer

Solution code:
def resolve():
    n = int(input())
    a = list(map(int,input().split()))
    x = [0]*n
#    for i in range(100): x[i] = i
#    j=10
#    print(x[j::j])
    for i in range(n):
        if sum(x[i::i+1])%2 != a[i]:
            x[i] += 1
    if all(a[i] == sum(a[i::i+1])%2 for i in range(n)):
        print(sum(x))
        for i in range(n):
            if x[i] == 1: print(i+1)
    else:
        print('-1')
  #  if a[i] = sum(a[::i])%2 
resolve()

Submission status: Wrong Answer

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

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

if N % 2 == 0:
    for i in range(N//2):
        ball[-i-1] = A[-i-1]
    num = N//2
else:
    for i in range(N//2+1):
        ball[-i-1] = A[-i-1]
    num = N//2


while num >= 1:
    c = num
    mod = 0
    while c < N:
        mod += ball[c]
        c += c
    if mod % 2 == 0:
        if A[num-1] == 1:
            ball[num] += 1
    else:
        if A[num-1] == 0:
            ball[num] += 1
    num -= 1

M = sum(ball)
print(M)
for i in range(N+1):
    if ball[i] != 0:
        print(i)

Submission status: Wrong Answer

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

l = len(a_ls)
N = [0]*l
# 大きい方からチェック
for i in range(l):
    a = a_ls[-(i+1)]
    s = sum(N[(l-i)-1::(l-i)])%2
    # print(s)
    # print(a)
    if a != s:
        N[-(i+1)]=1
        
sen = ""
for i,n in enumerate(N):
    if n == 1:
        sen += "{} ".format(i+1)

if len(sen) == 0:
    print(0)
else:
    print(sen[:-1])

Submission status: Wrong Answer

Solution code:
N = int(input())
a_ls = list(map(int,input().split(" ")))
N = [0]*N
l = len(a_ls)

# 大きい方からチェック
for i in range(l):
    a = a_ls[-(i+1)]
    s = sum(N[(l-i)-1::(l-i)])%2
    # print(s)
    # print(a)
    if a != s:
        N[-(i+1)]=1
        
sen = ""
for i,n in enumerate(N):
    if n == 1:
        sen += "{} ".format(i+1)

if len(sen) == 0:
    print(0)
else:
    print(sen[:-1])

Submission status: Wrong Answer

Solution code:
N = int(input())
a_ls = list(map(int,input().split(" ")))
N = [0]*N
l = len(a_ls)

# 大きい方からチェック
for i in range(l):
    a = a_ls[-(i+1)]
    s = sum(N[(l-i)-1::(l-i)])%2
    print(N[(l-i)-1::(l-i)])
    # print(s)
    # print(a)
    if a != s:
        N[-(i+1)]=1
        
sen = ""
for i,n in enumerate(N):
    if n == 1:
        sen += "{} ".format(i+1)

if len(sen) == 0:
    print(0)
else:
    print(sen[:-1])

Submission status: Wrong Answer

Solution code:
N = int(input())
a_ls = list(map(int,input().split(" ")))
N = [0]*N
l = len(a_ls)

for i in range(l):
    a = a_ls[-i]
    s = sum(N[(l-i)-1::(l-i)])%2
    if a != s:
        N[-i]=1
        print(i)

sen = ""
for i,n in enumerate(N):
    if n == 1:
        sen += "{} ".format(i+1)

if len(sen) == 0:
    print(0)
else:
    print(sen[:-1])

Submission status: Wrong Answer

Solution code:
N = int(input())
a_ls = list(map(int,input().split(" ")))
N = [0]*N
l = len(a_ls)

for i in range(l):
    a = a_ls[l-1-i]
    s = sum(N[(l-i)-1::(l-i)])%2
    if a != s:
        N[-i]=1
        print(i)

sen = ""
for i,n in enumerate(N):
    if n == 1:
        sen += "{} ".format(i+1)

if len(sen) == 0:
    print(0)
else:
    print(sen[:-1])

Submission status: Wrong Answer

Solution code:
N = int(input())
a_ls = list(map(int,input().split(" ")))
N = [0]*N
l = len(a_ls)

for i in range(l):
    a = a_ls[l-1-i]
    s = sum(N[(i+1)-1::(i+1)])%2
    if a != s:
        N[-i]=1

sen = ""
for i,n in enumerate(N):
    if n == 1:
        sen += "{} ".format(int(i+1))

if len(sen) == 0:
    print(0)
else:
    print(sen[:-1])

Submission status: Wrong Answer

Solution code:
N = int(input())
a_ls = list(map(int,input().split(" ")))
N = [0]*N
l = len(a_ls)

for i in range(l):
    a = a_ls[l-1-i]
    s = sum(N[(i+1)-1::(i+1)])%2
    if a != s:
        N[-i]=1

sen = ""
for i,n in enumerate(N):
    if n == 1:
        sen += "{} ".format(i+1)

if len(sen) == 0:
    print(0)
else:
    print(sen[:-1])

Submission status: Wrong Answer

Solution code:
N = int(input())
a_ls = list(map(int,input().split(" ")))
a_ls_rev = a_ls[::-1]
N_rev = [0]*N
l = len(a_ls)
for i,a in enumerate(a_ls_rev):
    s_2 = sum(N_rev[::(i+1)])%2
    if s_2 != a:
        N_rev[i]+=1
s = ""
for i,n in enumerate(N_rev[::-1]):
    if n == 1:
        s += "{} ".format(i+1)
if len(s) == 0:
    print(0)
else:
    print(s[:-1])

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):
    tmp = sum(a[i::i+1]) - a[i]
    #print(a[(idx-1)::(idx-i)],tmp)
    #print(i,tmp, a, a[i::i+1])
    if tmp % 2 == a[i]:
        continue
    else:
        ans.add(i+1)

cnt = len(ans)


if cnt == 0:
    print(0)
else:
    print(cnt)
    print(*ans)

Submission status: Wrong Answer

Solution code:

n = int(input())

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

idx = n//2 

ans = [0] * n

ans[idx:] = a[idx:]
#print("--", ans, idx)
for i in range(idx):
    tmp = sum(a[(idx-1)::(idx-i)])
    #print(a[(idx-1)::(idx-i)],tmp)
    if tmp % 2 == a[idx-i]:
        ans[idx-(i+1)] = 0
    else:
        ans[idx-(i+1)] = 1

cnt = sum(ans)


if cnt == 0:
    print(0)
else:
    print(cnt)
    print(*ans)