Problem:


Score : 400 points

Problem Statement

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

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

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

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

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

Constraints

All values in input are integers.

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

a_i is 0 or 1.

Input

Input is given from Standard Input in the following format:

N
a_1 a_2 ... a_N

Output

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

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

M
b_1 b_2 ... b_M

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

Sample Input 1

3
1 0 0

Sample Output 1

1
1

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

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

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

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

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

Sample Input 2

5
0 0 0 0 0

Sample Output 2

0

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



Sample input:
3
1 0 0


Sample output:
1
1

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
a_ball = [0 for _ in range(len(a))]
for a_index in range(n, 0, -1):
    count = 0
    for i in range(1, (n // a_index) + 1):
        # print(i, a_index)
        count += a_ball[a_index * i - 1]
    #もしボールの個数とラベルの数が合わなかったらボールを入れる
    if a[a_index - 1] != count:
        a_ball[a_index - 1] = 1
# print(a_ball)
print(a_ball.count(1))
[print(i) for i in range(1, len(a_ball)+1) if a_ball[i-1] == 1]

Submission status: Wrong Answer

Solution code:

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

M = 0
ans_lst = [0] * N
Nt = N
Nn = Nt // 2

t = 0
while Nt > 0:
    for i in range(Nn, Nt):
        t = 0
        for j in range(2*i, N, i+1):
            t += ans_lst[j]

        if (t + 1) % 2 == a_lst[i]:
            ans_lst[i] = 1

    Nt = Nn
    Nn = Nt // 2
    


m = 0
for i in range(N):
    m += ans_lst[i]
    


print(m)
ans_str = ""
for i in range(N):
    if ans_lst[i] == 1:
        if i != 0:
            ans_str += " "
        ans_str += str(i+1)
print(ans_str)

Submission status: Wrong Answer

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

ans = []
for i in range(len(inputs)):
    target = sum(inputs[i::i+1])
    if target % 2 == 1:
        ans.append(1)

if len(set(inputs)) == 1 and inputs[0] == 0:
    print(0)
else:
    if len(ans) == 0:
        print(-1)
    else:
        print(len(ans))
        if len(ans) != 0:
            print(' '.join(map(str, ans)))

Submission status: Wrong Answer

Solution code:

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

M = 0
ans_lst = [0] * N
Nt = N
Nn = Nt // 2


while Nt > 0:
    for i in range(Nn, Nt):
        t = 0
        for j in range(2*i, N, i+1):
            t += a_lst[j]
        ans_lst[i] = (a_lst[i] + t) % 2

    Nt = Nn
    Nn = Nt // 2
    


m = 0
for i in range(N):
    m += ans_lst[i]
    


print(m + a_lst[0])
ans_str = ""
for i in range(N):
    if ans_lst[i] == 1:
        ans_str += str(i+1)
        if i != N - 1:
            ans_str += " "
print(ans_str)

Submission status: Wrong Answer

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

for i in range(N//2, 0, -1):
    tmp = 0
    j = i
    while j < N+1:
        tmp += A[j]
        j += j
    A[i] = tmp % 2
    # A[i] = sum(A[i::i]) % 2
ans = [i for i, j in enumerate(A) if j == 1]

print(len(ans))
print(*ans)

Submission status: Wrong Answer

Solution code:
#import sys
#input = sys.stdin.readline
def main():
    N = int( input())
    A = list( map( int, input().split()))
    ANS = [0]*N
    for i in range(N,0,-1):
        t = sum([ANS[i*(j+1)-1] for j in range(N//i)] )%2
        if t == A[i-1]:
            continue
        ANS[i-1] = 1
    print( sum(ANS))
    print( " ".join( map( str, [ i+1 for i in range(N) if A[i] == 1])))
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N = int(input())
box = list(map(int,input().split()))
li = []
for i in reversed(range(1,N+1)):
    count = 0
    for j in range(i,N+1,i):
        if j%i == 0 and box[j-1] == 1:
            if not j in li:
                count += 1
    if count % 2 == 1:
        li.append(i)
if li == []:
    print(0)
else:
    print(len(li))
    for i in li:
        print(i, end='')

Submission status: Wrong Answer

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

for i in xrange(n,0,-1):
    if b[i]==1:
        j=1
        cntl[i]+=1        
        while j*j<=i:
            if i%j==0:
                b[j]=0
                cntl[j]+=1
                if i/j!=j and i/j!=i :
                    cntl[i/j]+=1
                    b[i/j]=0
            j+=1

#print b            
#print cntl,12
for i in xrange(n,0,-1):
    if cntl[i]&a[i]!=a[i]:
        cntl[i]+=1
        j=1
        while j*j<=i:
            if i%j==0:
                cntl[j]+=1
                if i/j!=j and i/j<i: 
                   cntl[i/j]+=1
            j+=1
        b[i]=1
#print b
#print cntl,12
ans=[]
m=0
for i in xrange(n,0,-1):
    if cntl[i]&a[i]!=a[i]:
        m=-1
        break
    if b[i]&1:
        ans.append(str(i))
        m=m+1
ans.reverse()             
print m
if m>-1:
    print " ".join(ans)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(4100000)

import logging

logging.basicConfig(level=logging.DEBUG)

logger = logging.getLogger(__name__)


# @profile
def resolve():
    N = [int(x) for x in sys.stdin.readline().split()][0]
    a_list = [int(x) for x in sys.stdin.readline().split()]

    logger.debug('{} {}'.format(N, a_list))

    box_list = [0 for _ in range(N)]

    for i in reversed(range(N)):
        suma = sum(box_list[i+1:N:i+1])

        r = suma % 2
        if r != a_list[i]:
            box_list[i] = 1

    s = sum(box_list)
    print(s)

    if s > 0:
        print(' '.join(
            [str(i + 1) for i in range(len(box_list)) if box_list[i]]))


if __name__ == "__main__":
    resolve()

# AtCoder Unit Test で自動生成できる, 最後のunittest.main は消す
# python -m unittest template/template.py で実行できる
# pypy3 -m unittest template/template.py で実行できる

import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """3
1 0 0"""
        output = """1
1"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """5
0 0 0 0 0"""
        output = """0"""
        self.assertIO(input, output)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict

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

d = defaultdict(int)

#約数を求める
def makeDivisor(n):
    for i in range(1, int(n ** 0.5)+1):
        if n % i == 0:
            d[i] += 1
            if i != n // i:
                d[i] += 1
    return

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

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

Submission status: Wrong Answer

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

for i in range(N-1, -1, -1):
    tmp = 0
    for t in range(i, N, i+1):
        tmp += A[t]
    if tmp == i+1:
        break

print(tmp)
for i in range(1, tmp+1):
    if i % tmp == 0:
        print(i)

Submission status: Wrong Answer

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

ans = [0] * N
for i in range(N,0,-1):
    ts = sum(ans[i:N:i])
    if ts % 2 != A[i-1]: ans[i-1] = 1

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

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int, input().split()))
b = [0 for i in range(N)]#玉を収納していくリスト

def check(i):
#Nには箱の番号（aのindex+1)を大きい順に入れる
    n = i
    cnt = 0
    #aaの倍数の箱に入っている玉の数をカウント
    while n <= N:
        cnt += b[n-1]
        n += i
        #aaを2倍、3倍、、、としていく
    return cnt

for i in range(N-1, -1, -1):
    if (a[i]+check(i+1))%2 == 1:
        b[i] = 1
    
ans = sum(b)
bb = [str(i) for i in b]

if ans == 0:
    print(ans)
else:
    print(ans)
    print(" ".join(bb))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
ans = [0 for i in range(n)]
def sum_array(ans, k):
    sum = 0
    for i in range(n):
        if (i + 1) % (k + 1) == 0:
            sum += ans[i]
    return sum
for i in range(n):
    if sum_array(ans, n - i - 1) % 2 != a[n - i - 1]:
        ans[n - i - 1]  += 1
print(sum(ans))
for i in range(n):
    print("{} ".format(ans[i]), end = '')

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [0] + list(map(int, input().split()))
ans = [0]*(n+1)
for i in range(n, n//2, -1) : ans[i] = a[i]
for i in range(n//2, 0, -1) : ans[i] = (sum(a[i+i:n+1:i])+a[i])%2
print(sum(ans))
for i in range(1, n+1) : ans[i] *= i
print(" ".join(map(str, list(filter(lambda x:x!=0, ans)))))

Submission status: Wrong Answer

Solution code:
import math
N = int(input())
a_array = list(map(int,input().split()))
ans_array = [] 
now_ball_array = [0] * N

for i in range(N-1,-1,-1):
    if a_array[i] != now_ball_array[i]:
        ans_array.append(str(i+1))
        box_root = math.ceil(math.sqrt(i+1))
        if box_root * box_root == (i+1):
            now_ball_array[box_root-1] = now_ball_array[box_root-1] & 0 
        for j in range(1,box_root):
            if (i+1) % j == 0:
                now_ball_array[j-1] = now_ball_array[j-1] & 0 
                now_ball_array[(i+1)//j-1] = now_ball_array[(i+1)//j-1] & 0 

print(len(ans_array))
if len(ans_array):
    print(" ".join(ans_array))

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):
    if sum(b[i::i]) % 2 != a[i]:
        b[i] = 1
    else:
        b[i] = 0

M = b.count(1)
print(M)
print('1 ' * M)

Submission status: Wrong Answer

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

for i in range(1,n+1)[::-1]:
    ball_sum = sum(a[2*i::i]) % 2
    if ball_sum ^ a[i]:
        balls[i] = 1
    else:
        balls[i] = 0

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

Submission status: Wrong Answer

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

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

    a[i] = x

ans = []
for i, ai in enumerate(a):
    if ai == 1:
        ans.append(i)

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

Submission status: Wrong Answer

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

b=[-1]*(n+1)

bgn=n//2+1

for i in range(bgn,n+1):
    b[i]=a[i]

for i in range(bgn-1,0,-1):
    j=i
    cnt=0
    while j<=n:
        cnt+=a[j]
        j+=i
    res=cnt%2
    if res==a[i]:b[i]=a[i]
    else:b[i]=1

if b.count(1)>0:
    print(len(b)-1)
    print(*b[1:])
else:print(0)

Submission status: Wrong Answer

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

b=[-1]*(n+1)

bgn=n//2+1

for i in range(bgn,n+1):
    b[i]=a[i]

for i in range(bgn-1,0,-1):
    j=i
    cnt=0
    while j<=n:
        cnt+=a[j]
        j+=i
    res=cnt%2
    if res==a[i]:b[i]=a[i]
    else:b[i]=1

print(b.count(1))
for i in range(len(b)):
    if b[i]==1:print(1,sep=' ')

Submission status: Wrong Answer

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

b=[-1]*(n+1)

bgn=n//2+1

for i in range(bgn,n+1):
    b[i]=a[i]

for i in range(bgn-1,0,-1):
    j=i
    cnt=0
    while j<=n:
        cnt+=a[j]
        j+=i
    res=cnt%2
    if res==a[i]:b[i]=a[i]
    else:b[i]=1

print(b.count(1))
for i in range(len(b)):
    if b[i]==1:print(1)

Submission status: Wrong Answer

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

b = [0] * (N//2) + a[(N//2):]
M = a[(N//2):].count(1)

for i in range(N//2, 0, -1):
    if sum(b[i::i]) % 2 != a[i]:
        b[i] = 1
        M += 1
print(M)

for i in range(M):
    print(1, '', end='')

Submission status: Wrong Answer

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

b=[-1]*(n+1)

bgn=n//2+1

for i in range(bgn,n+1):
    b[i]=a[i]

for i in range(bgn-1,0,-1):
    j=i
    cnt=0
    while j<=n:
        cnt+=a[j]
        j+=i
    res=cnt%2
    if res==a[i]:b[i]=a[i]
    else:b[i]=1

print(b.count(1))
print(*b[1:])

Submission status: Wrong Answer

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


for i in range(N-1, -1, -1):
    for j in [0, 1]:
        b[i] = j
        if sum(b[i::i+1]) % 2 == a[i]:
            if j == 1:
                c.append("1")
            break
    else:
        print("-1")
        exit()

M = sum(b)
print(M)
ans = ' '.join(c)
print(ans)

Submission status: Wrong Answer

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

for i in range(N, 0, -1):
    if sum(b[i::i]) % 2 != a[i]:
        b[i] = a[i]
    M += b[i]

print(M)

for i in range(M):
    print(1, '', end='')

Submission status: Wrong Answer

Solution code:
from sys import exit, stderr
from inspect import currentframe
def debug(*args):
    names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}
    print(', '.join(names.get(id(arg),'???')+' = '+repr(arg) for arg in args), file=stderr)
    return
N = int(input())
a = [int(_) for _ in input().split()]
b = set()
out = []
n = 0
for i in range(N-1, -1, -1):
    if a[i] == 1:
        out.append(i + 1)
        n += 1
        # print(i+1)
        for f in range(1, int((i+1)**0.5)+2):
            if (i+1)%f == 0:
                a[f-1] = 0 if a[f-1] == 1 else 1
                if f != (i+1)//f and f != 1:
                    a[(i+1)//f-1] = 0 if a[(i+1)//f-1] == 1 else 1
    # debug(a)
print(n)
# print(b)
if len(out) > 0:
    for i in range(len(out)):
        print(out[i], end=" ")
    print()

Submission status: Wrong Answer

Solution code:
from sys import exit, stderr
from inspect import currentframe
def debug(*args):
    names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}
    print(', '.join(names.get(id(arg),'???')+' = '+repr(arg) for arg in args), file=stderr)
    return
N = int(input())
a = [int(_) for _ in input().split()]
b = set()
out = []
n = 0
for i in range(N-1, -1, -1):
    if a[i] == 1:
        out.append(i + 1)
        n += 1
        # print(i+1)
        for f in range(1, int((i+1)**0.5)+2):
            if (i+1)%f == 0:
                a[f-1] = 0 if a[f-1] == 1 else 1
                if f != (i+1)//f and f != 1:
                    a[(i+1)//f] = 0 if a[(i+1)//f] == 1 else 1
    # debug(a)
print(n)
# print(b)
if len(out) > 0:
    for i in range(len(out)):
        print(out[i], end=" ")
    print()

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
a2 = [0 for _ in range(len(a))]
for a_index in range(n, 0, -1):
    count = 0
    for i in range(1, (n // a_index) + 1):
        # print(i, a_index)
        count += a[a_index * i - 1]
    a2[a_index - 1] = count % 2
# print(a2)
print(a2.count(1))
[print(i) for i in range(1, len(a2)+1) if a2[i-1] == 1]

Submission status: Wrong Answer

Solution code:
# from sys import exit, stderr
# from inspect import currentframe
# def debug(*args):
#     names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}
#     print(', '.join(names.get(id(arg),'???')+' = '+repr(arg) for arg in args), file=stderr)
#     return
N = int(input())
a = [int(_) for _ in input().split()]
b = set()
out = []
n = 0
for i in range(N-1, -1, -1):
    if a[i] == 1:
        out.append(i + 1)
        n += 1
        for f in range(1, int((i+1)**0.5)+2):
            if (i+1)%f == 0:
                a[f-1] = 0 if a[f-1] == 1 else 1
print(n)
# print(b)
if len(out) > 0:
    for i in range(len(out)):
        print(out[i], end=" ")
    print()

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
a2 = [0 for _ in range(len(a))]
for a_num in range(n, 0, -1):
    count = a[a_num - 1]
    for i in range(1, ((n + a_num - 1) // a_num)):
        
        count += a2[a_num * i - 1]
    a2[a_num - 1] = count % 2
print(a2.count(1))
[print(i) for i in range(1, len(a2)+1) if a2[i-1] == 1]

Submission status: Wrong Answer

Solution code:
# from sys import exit, stderr
# from inspect import currentframe
# def debug(*args):
#     names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}
#     print(', '.join(names.get(id(arg),'???')+' = '+repr(arg) for arg in args), file=stderr)
#     return
N = int(input())
a = [int(_) for _ in input().split()]
b = set()
out = []
n = 0
for i in range(N-1, -1, -1):
    if a[i] == 1:
        out.append(i + 1)
        n += 1
        for f in range(1, int((i+1)**0.5+1)):
            if (i+1)%f == 0:
                a[f-1] = 0 if a[f-1] else 1

print(n)
# print(b)
if len(out) > 0:
    for i in range(len(out)):
        print(out[i], end=" ")
    print()

Submission status: Wrong Answer

Solution code:
# from sys import exit, stderr
# from inspect import currentframe
# def debug(*args):
#     names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}
#     print(', '.join(names.get(id(arg),'???')+' = '+repr(arg) for arg in args), file=stderr)
#     return
N = int(input())
a = [int(_) for _ in input().split()]
b = set()
out = []
n = 0
for i in range(N-1, -1, -1):
    if a[i] == 1:
        out.append(i + 1)
        n += 1
    for f in range(1, int((i+1)**0.5+1)):
        if (i+1)%f == 0:
            a[f-1] = 0 if a[f-1] else 1

print(n)
# print(b)
if len(out) > 0:
    for i in range(len(out)):
        print(out[i], end=" ")
    print()

Submission status: Wrong Answer

Solution code:
# from sys import exit, stderr
# from inspect import currentframe
# def debug(*args):
#     names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}
#     print(', '.join(names.get(id(arg),'???')+' = '+repr(arg) for arg in args), file=stderr)
#     return
N = int(input())
a = [int(_) for _ in input().split()]
b = set()
out = []
n = 0
for i in range(N-1, -1, -1):
    if a[i] == 1:
        out.append(i + 1)
    for f in range(int(n**0.5)):
        if (i+1)%f == 0:
            a[f-1] = 0 if a[i] else a[i]

print(n)
# print(b)
if len(out) > 0:
    for i in range(len(out)):
        print(out[i], end=" ")
    print()

Submission status: Wrong Answer

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

b = [0] + [0] * (N//2) + a[(N//2):]
M = a[(N//2):].count(1)

for i in range(N//2, 0, -1):
    if sum(b[i::i]) % 2 != a[i]:
        b[i] = not a[i]
        M += not a[i]
print(M)

for i in range(M):
    print(1, '', end='')

Submission status: Wrong Answer

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

#0～NのN+1個のindexを持っていてこのうち1～Nを使う
#iの倍数を使うので0indexは都合が悪い
#Asの先頭はダミー,Bsは正解の列(ボール有:1、ボール無:0)
As = [-1] + As
Bs = [0 for _ in range(N+1)]

#N,N-1,N-2,...,3,2,1
for i in reversed(range(1,N+1)):
	tmpS = 0
	#iの倍数の箱があれば積み上げる
	for j in range(2*i,N+1,i):
		tmpS += Bs[j]
		
	#合計とAs[i]が異なると、補正するためにBsに1を
	#それ以外は0なのでデフォルトのまま何もしない
	if tmpS % 2 != As[i]:
		Bs[i] = 1

anss = []
#1のindexを抽出とjoinを使うため文字列化
for i in range(N+1):
	if Bs[i] == 1:
		anss.append(str(i))
		
print(len(anss))
print("".join(anss))

Submission status: Wrong Answer

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

b = [0] + [0] * (N//2) + a[(N//2):]
M = a[(N//2):].count(1)

for i in range(N//2, 0, -1):
    total = sum(b[i::i])
    x = (total + a[i]) % 2
    M += x
    b[i] = x
print(M)

for i in range(M):
    print(1, '', end='')

Submission status: Wrong Answer

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

temp = [0]*N
for i in range(N-1,-1,-1):
  for j in [0,1]:
    temp[i] = j
    if sum(temp[i::i+1])%2 == A[i]:
      break
  else:
    print(-1)
    exit()
print(sum(temp)) 
anslist = []
for i in range(N):
  if temp[i] == 1:
    anslist.append(i+1)
  if anslist == []:
      exit()
  else:
    print(*anslist)
    exit()

Submission status: Wrong Answer

Solution code:
n=int(input())
list = list(map(int,input().split()))
ans_list = []
for i in reversed(range(n)):
  x=0
  for j in range(int(n//(i+1))):
    if (i+1)*j in ans_list:
      x += 1
    
  if x%2 != list[i]:
    ans_list.append(i+1)

ans_list = [str(k) for k in ans_list]
print(len(ans_list))
print(' '.join(ans_list))

Submission status: Wrong Answer

Solution code:
import sys

N = int(input())

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

b = [0] * (N+1)

num = 0

for i in range(N, 0, -1):
    sum = 0
    for j in range(i+i, N+1, i):
        if j < len(a):
            sum ^= b[j]
        else:
            break

        b[i] = sum ^ a[i]
        if b[i] == 1:
            num += 1

print(num)

if num == 0 or num == -1:
    sys.exit(0)

flag = False

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

print("")

Submission status: Wrong Answer

Solution code:
import sys

N = int(input())

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

b = [0] * (N+1)

num = 0

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

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

print(num)

if num == 0 or num == -1:
    sys.exit(0)

flag = False

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

print("")

Submission status: Wrong Answer

Solution code:
import sys, math, itertools, bisect, copy, re
from collections import Counter, deque, defaultdict

# from itertools import accumulate, permutations, combinations, takewhile, compress, cycle
# from functools import reduce
# from math import ceil, floor, log10, log2, factorial
# from pprint import pprint

INF = float('inf')
MOD = 10 ** 9 + 7
EPS = 10 ** -7
sys.setrecursionlimit(1000000)


# N = int(input())
# N,M = [int(x) for x in input().split()]
# V = [[0] * 100 for _ in range(100)]
# A = [int(input()) for _ in range(N)]
# DP = [[0] * 100 for _ in range(100)]
# DP = defaultdict(lambda: float('inf'))

def divisor_list(n):
    ret = set()
    i = 1
    while i * i <= n:
        if n % i == 0:
            ret.add(i)
            ret.add(n // i)
        i += 1
    return ret


N = int(input())
tmp = [int(x) for x in input().split()]
A = [-999]
for a in tmp:
    A.append(a)

B = []

for i in range(N, 0, -1):
    # print(i)
    if A[i] == 1:
        B.append(str(i))
        DL = divisor_list(i)
        for j in DL:
            A[j] = (A[j] + 1) % 2

print(" ".join(B))

pass

Submission status: Wrong Answer

Solution code:
n = int(input())

a = [int(i) for i in input().split()]
b = [0 for i in range(n)]
ans = []

for ai, i in zip(reversed(a), reversed(range(1, n))):
    q = (n + 1) // (i + 1)
        
    if q >= 2:
        s = 0
        for j in range(2, q+1):
            s += b[i*j-1]
        if ai != s % 2:
            b[i] = 1
            ans.append(i+1)
    else:
        if ai == 1:
            b[i] = ai
            ans.append(i+1)

if a[0] != sum(b) % 2:
    b[0] = 1
    ans.append(1)
        
print(len(ans))
print(' '.join(map(str, ans)))

Submission status: Wrong Answer

Solution code:
n = int(input())

a = [int(i) for i in input().split()]
b = [0 for i in range(n)]
ans = []

for ai, i in zip(reversed(a), reversed(range(1, n))):
    q = (n + 1) // (i + 1)
        
    if q >= 2:
        s = 0
        for j in range(2, q+1):
            s += b[i*j-1]
        r = s % 2
    else:
        r = 0
    
    if ai != r:
        b[i] = 1
        ans.append(i+1)

if a[0] != sum(b) % 2:
    b[0] = 1
    ans.append(1)
        
print(len(ans))
print(' '.join(map(str, ans)))

Submission status: Wrong Answer

Solution code:

n = int(input())

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

#mid = n//2 + n%2

#print(* range(10)[::2] )

ans = [0]*(n+1)

for _ in range(n):# 0 ... n-1
    i = n-_ # n ... 1

    ta = sum(ans[i-1::i])
    ans[i] = 0 if ta%2 == an[i-1] else 1

#    print(i, an[i-1::i])


m = sum(ans)
print(m)

if m > 0:
    print(*[i for i, x in enumerate(ans) if x >0])

Submission status: Wrong Answer

Solution code:

n = int(input())

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

#mid = n//2 + n%2

#print(* range(10)[::2] )

ans = [0]*(n+1)

for _ in range(n):# 0 ... n-1
    i = n-_ # n ... 1

    ta = sum(ans[i-1::i])
    ans[i] = an[i-1] if ta%2 == an[i-1] else 1

#    print(i, an[i-1::i])


m = sum(ans)
print(m)

if m > 0:
    print(*[i for i, x in enumerate(ans) if x >0])

Submission status: Wrong Answer

Solution code:

n = int(input())

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

#mid = n//2 + n%2

#print(* range(10)[::2] )

ans = [0]*(n+1)

for _ in range(n):# 0 ... n-1
    i = n-_ # n ... 1

    ta = sum(an[i-1::i])
    ans[i] = an[i-1] if ta%2 == an[i-1] else 1

#    print(i, an[i-1::i])


m = sum(ans)
print(m)

if m > 0:
    print(*[i for i, x in enumerate(ans) if x >0])

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
a2 = [0 for _ in range(len(a))]
for a_num in range(n, 0, -1):
    count = a[a_num - 1]
    for i in range(1, (n + a_num - 1) // a_num):
        
        count += a2[a_num * i - 1]
    a2[a_num - 1] = count % 2
print(a2.count(1))
[print(i) for i in range(1, len(a2)+1) if a2[i-1] == 1]

Submission status: Wrong Answer

Solution code:

n = int(input())

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

#mid = n//2 + n%2

#print(* range(10)[::2] )

ans = [0]*(n+1)

for _ in range(n):
    i = n-_

    ta = sum(an[i-1::i])
    ans[i] = ta

#    print(i, an[i-1::i])


m = sum(ans)
print(m)

if m > 0:
    print(*[i for i, x in enumerate(ans) if x >0])

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
a2 = [0 for _ in range(len(a))]
for a_num in range(n, 0, -1):
    count = a[a_num - 1]
    for i in range(1, (n + a_num - 1) // a_num):
        
        count += a2[(a_num - 1) * i]
    a2[a_num - 1] = count % 2
print(a2.count(1))
[print(i) for i in range(1, len(a2)+1) if a2[i-1] == 1]

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
a2 = [0 for _ in range(len(a))]
for a_num in range(n, 0, -1):
    count = a[a_num - 1]
    for i in range(1, (n + a_num - 1) // a_num):
        
        count += a2[a_num - 1 * i]
    a2[a_num - 1] = count % 2
print(a2.count(1))
[print(i) for i in range(1, len(a2)+1) if a2[i-1] == 1]

Submission status: Wrong Answer

Solution code:
#coding : utf-8

import os
import sys

N = int(input())

a = list(map(lambda x: int(x), input().split(" ")))

#print(N)
#print(a)

box = [0 for i in range(N)]

#print(box)

for i in range(N, 0, -1):
	#print(f"i={i}, a{i}={a[i-1]}")

	idx = []
	for k in range(1, N+1):
		v = i * k
		if v > N:
			break
		idx.append(v)

	idx.reverse()

	#print(idx)

	balls = 0
	for k in idx:
		balls += box[k-1]
	
	#print(balls)

	if a[i-1] == 0:
		if balls == 0:
			box[i-1] = 0
		else:
			box[i-1] = 1
	else:
		if balls == 0:
			box[i-1] = 1
		else:
			box[i-1] = 0

#print(box)


print(box.count(1))

for i, b in enumerate(box):
	if b == 1:
		print(i+1)

Submission status: Wrong Answer

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

nums = []
memo = [0] * N
for i in range(N - 1, -1, -1):
    if A[i] != sum(memo[i :: i + 1]) % 2:
        memo[i] = 1
        nums.append(A[i])
        
print(sum(memo))
print(' '.join(map(str, nums)))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [int(i) for i in input().split()]
 
nums = []
memo = [0] * N
for i in range(N - 1, -1, -1):
    if sum(A[i : :i + 1]) % 2 != sum(memo[i :: i + 1]) % 2:
        memo[i] = 1
        nums.append(A[i])
        
print(sum(memo))
print(' '.join(map(str, nums)))

Submission status: Wrong Answer

Solution code:

n = int(input())

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

#mid = n//2 + n%2

ans = [0]*n
for i, a in enumerate(an[::-1]):

#    ta = [x for ii,x in enumerate(an[i:]) if i % (n-(ii+i)) == 0]
#    t = sum(ta)
#    print(ta,t,i,a)
#    ans[-i] = t%2

    ans[-i] = sum([x for ii, x in enumerate(an[i::(i+1)]) if i % (n-(ii+i)) == 0])%2

m = sum(ans)
print(m)

if m > 0:
    print(*[1+i for i,x in enumerate(ans) if x >0])

Submission status: Wrong Answer

Solution code:

n = int(input())

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

#mid = n//2 + n%2

ans = [0]*n
for i, a in enumerate(an[::-1]):

#    ta = [x for ii,x in enumerate(an[i:]) if i % (n-(ii+i)) == 0]
#    t = sum(ta)
#    print(ta,t,i,a)
#    ans[-i] = t%2

    ans[-i] = sum([x for ii, x in enumerate(an[i::(i+1)]) if i % (n-(ii+i)) == 0])%2

m = sum(ans)
print(m)

if m > 0:
    print(*[x for x in ans if x >0])

Submission status: Wrong Answer

Solution code:
# ABC134D - Preparing Boxes
def main():
    n = int(input())
    A = [0] + list(map(int, input().rstrip().split()))
    ans = [0] * (n + 1)
    for i in range(n, 0, -1):
        cnt, p = 0, 2
        while i * p <= n:
            cnt += ans[i * p]
            p += 1
        if cnt % 2 != A[i]:
            ans[i] += 1
    print(sum(ans))


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import heapq
from collections import defaultdict
cnt = defaultdict(int)
N = int(input())
A = list(map(int, input().split()))
# A = []
# for i in range(N):
#     A.append(int(input()))
if sum(A) == 0:
    print(0)
    exit()
ans = 0
_ans = []
buff = [0 for i in range(N)]
for i in range(N-1, -1, -1):
    if i > N//2:
        buff[i] = A[i]
    else:
        _m = 0
        # for j in range(i, N, max(1, i)):
        #     _m += buff[j]
        # _m = sum(buff[i:N])
        for j in range(i*2, N, max(1, i)):
            _m += buff[j]
        if _m % 2 != A[i]:
            buff[i] = 1
            ans += 1
            _ans.append(i+1)

mm = 0
for i in range(ans):
    if buff[i] == 1:
        mm = i

print(sum(buff))
print(*_ans)