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 ** 7)
input = sys.stdin.readline

n = int(input())

a = list( map(int, input().split()))
b=[]
c = [0]*n
ans = 0

for i in reversed(range(n)):
    if a[i] > 1:
        print(-1)
        exit()
    cnt = n // (i+1)
    tmp = 0
    for j in range(2,cnt):
        tmp += c[(i+1) * j-1]
    tmp2 = (tmp%2+a[i])%2
    c[i] = tmp2
    ans += tmp2
    if tmp2 == 1:
        b.append(i+1)
b.sort()
print(ans)
print(*b, sep=' ')

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

n = int(input())

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

for i in reversed(range(n)):
    if a[i] > 1:
        print(-1)
        exit()
    cnt = n // (i+1)
    tmp = 0
    for j in range(2,cnt):

        tmp += a[(i+1) * j]
    tmp2 = (tmp%2+a[i])%2
    ans += tmp2
    if tmp2 == 1:
        b.append(i+1)

b.sort()
print(ans)
print(*b, sep=' ')

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

n = int(input())

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

for i in reversed(range(n)):
    if a[i] > 1:
        print(-1)
        exit()
    cnt = n // (i+1)
    tmp = 0
    for j in range(2,cnt):

        tmp += a[(i+1) * j]
    tmp2 = (tmp%2+a[i])%2
    ans += tmp2
    if tmp2 == 1:
        b.append(i+1)

print(ans)
print(*b, sep=' ')

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
jud = [0] * n
ans = []
for i in range(n//2, n):
    if a[i] == 1:
        jud[i] = 1
        ans.append(i+1)
for i in range(n//2-1, -1, -1):
    cou = 0
    for j in range(2, n//(i+1)):
        cou ^= jud[(i+1)*j-1]
    if a[i] != cou:
        jud[i] = 1
        ans.append(i+1)
print(jud.count(1))
print(*ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
ans = set()
for i in range(n,0,-1):
    count = 0
    for j in range(1,n//i+1):
        if j in ans:
            count += 1
    if count % 2 != a[i-1] :
        ans.add(i)
ans = list(ans)
ans.sort()
print(len(ans))
print(" ".join(map(str,ans)))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
ans = set()
for i in range(n,0,-1):
    count = 0
    for j in range(1,n//i+1):
        if j in ans:
            count += 1
    if count % 2 != a[i-1] :
        ans.add(i)
print(len(ans))
print(" ".join(map(str,ans)))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
ans = set()
for i in range(n,0,-1):
    count = 0
    for j in range(1,n//i+1):
        if j in ans:
            count += 1
    if count % 2 != a[i-1] :
        ans.add(i)
print(len(ans))
if ans:
    print(" ".join(map(str,ans)))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
ans = set()
for i in range(n,0,-1):
    count = 0
    for j in range(1,n//i+1):
        if j in ans:
            count += 1
    if count % 2 != a[i-1] :
        ans.add(i)
print(len(ans))
if ans:
    print("".join(map(str,ans)))

Submission status: Wrong Answer

Solution code:
n=int(input())

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

for i in reversed(range(1,n+1)):
    if sum(A[::i])%2!=A[i]:
        A[i]=1
        
print(sum(A))
if sum(A)!=0:
    for i,a in enumerate(A):
        if a==1:
            print(i)

Submission status: Wrong Answer

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
A = LIST()
# ball を入れたら1
ball = [0] * (N+1)
for i in range(N, 0, -1):
    # if i > N // 2:
    # ball[i] += A[i-1]
    tmp = 0
    # i 以外での偶奇が違うとき：1
    # 同じとき：0
    for j in range(i, N+1, i):
        if j == i:
            pass
        else:
            tmp ^= ball[j-1]
    if tmp == A[i-1]:
        ball[i] = 0
    else:
        ball[i] = 1
print(sum(ball))
for i, b in enumerate(ball):
    if b == 1:
        print(i, end=" ")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#134_D
n=int(input())
a=[0]+list(map(int,input().split()))
b=[0 for _ in range(n+1)]
for i in range(n,0,-1):
    if i<=n//2:
        b[i]=a[i]
    else:
        b[i]=int(sum([b[k] for k in range(i*2,n+1,i)])%2!=a[i])
print(sum(b))
if sum(b)>0:
    ans=[]
    for i in range(1,n+1):
        if b[i]==1:
            ans.append(i)
    print(*ans)

Submission status: Wrong Answer

Solution code:
#134_D
n=int(input())
a=[0]+list(map(int,input().split()))
b=[0 for _ in range(n+1)]
for i in range(n,0,-1):
    if i<=n//2:
        b[i]=a[i]
    else:
        b[i]=int(sum([b[k] for k in range(i*2,n,i)])%2!=a[i])
print(sum(b))
if sum(b)>0:
    ans=[]
    for i in range(1,n+1):
        if b[i]==1:
            ans.append(i)
    print(*ans)

Submission status: Wrong Answer

Solution code:
#134_D
n=int(input())
a=[0]+list(map(int,input().split()))
b=[0 for _ in range(n+1)]
for i in range(n,0,-1):
    if i<=n//2:
        b[i]=a[i]
    else:
        b[i]=sum([a[k] for k in range(2*i,n,i)])%2
print(sum(b))
if sum(b)>0:
    ans=[]
    for i in range(1,n+1):
        if b[i]==1:
            ans.append(i)
    print(*ans)

Submission status: Wrong Answer

Solution code:
#134_D
n=int(input())
a=[0]+list(map(int,input().split()))
b=[0 for _ in range(n+1)]
for i in range(n,0,-1):
    if i<=n//2:
        b[i]=a[i]
    else:
        b[i]=sum([a[k] for k in range(2*i,n,i)])
print(sum(b))
if sum(b)>0:
    ans=[]
    for i in range(1,n+1):
        if b[i]==1:
            ans.append(i)
    print(*ans)

Submission status: Wrong Answer

Solution code:
def main():
    box = int(input())
    target = [0] + list(map(int, input().split()))
    balls = [0] * (box + 1)
    put = []
    for i in range(box, 1, -1):
        if i * 2 <= box:
            if target[i] == target[2 * i]:
                continue
            else:
                balls[i] += 1
                put.append(str(i))
        elif target[i] == 1:
            balls[i] += 1
            put.append(str(i))
    all_balls = sum(balls)
    if all_balls % 2 == target[1] or (all_balls == 0 and target[1] == 1):
        if all_balls == 0 and target[1] == 1:
            all_balls += 1
            put.append("1")
        print(all_balls)
        if all_balls > 0:
            print(" ".join(put))
    else:
        print(-1)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    A = [int(i) for i in input().split()]
    B = [0]*N
    for i in range(N)[::-1]:
        cur_sum = -A[i]
        for j in range(i, N, i+1):
            cur_sum += A[j]
        if cur_sum % 2 != A[i] % 2:
            B[i] = 1
    # print(B)
    ans = [i+1 for i, b in enumerate(B) if b]
    print(len(ans))
    if ans:
        print(*ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
# Problem D - Preparing Boxes

# input and initialization
N = int(input())
a_list = list(map(int, input().split()))
current_num = [0]*N

M = 0
b_list = []
is_equivalent = True

for i in reversed(range(1,N+1)):
    num = 1
    for j in range(i,N+1,i):
        if current_num[j-1]==1:
            num = num + 1
    if num%2==a_list[i-1]:
        current_num[i-1] = 1

for i in range(N):
    if not current_num[i]==a_list[i]:
        is_equivalent = False
        break
    elif current_num[i]>=1:
        M = M + 1
        b_list.append(i+1)

# output process
if is_equivalent:
    print(M)
    for b in b_list:
        print(b, end=" ")
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
n, *a = map(int, open(0).read().split())

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

print(sum(ans))
for i in range(n):
    if ans[i]: print(i+1)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
b = [0] * (n + 1)
# 後ろからボールの有無を決定
for i in range(n, 0, -1):
    cnt = sum(b[::i])
    # 条件と異なるならボールを投入
    if cnt % 2 != a[i - 1]:
        b[i] = 1
m = sum(b)
print
for i in range(1, n + 1):
    if b[i]:
        print(i, end=' ')

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
b = [0] * n
# 後ろからボールの有無を決定
for i in range(n, 0, -1):
    cnt = sum(b[::i])
    # 条件と異なるならボールを投入
    if cnt % 2 != a[i - 1]:
        b[i - 1] = 1
m = sum(b)
print(m)
for i in range(n):
    if b[i]:
        print(i + 1, end=' ')

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):
    cnt = 0
    for j in range(2 * (i + 1), n + 1, i + 1):
        if b[j - 1] == 1:
            cnt += 1
    if cnt % 2 != a[i] % 2:
        b[i] = 1
m = b.count(1)
print(m)
for _ in range(m):
    print(1, end=' ')

Submission status: Wrong Answer

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

    def Eratosthenes(x: int) -> set:
        import math
        sup = int(x)
        primes = {i for i in range(2, sup+1)}
        for i in range(2, int(math.sqrt(sup+1))+1):
            if i in primes:
                mul = 2
                while i*mul <= sup:
                    primes.discard(i*mul)
                    mul += 1
        return primes

    primes = Eratosthenes(N)
    sumA = sum(A)
    if A[0] != sumA % 2:
        return print(-1)

    for i, a in enumerate(A[1:]):
        if a and i+2 not in primes:
            return print(-1)

    ans = [i+1 for i, a in enumerate(A) if a]
    print(len(ans))
    if ans:
        print(*ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
cnt = a.count(1)
if cnt == 0:
    print(cnt)
else:
    print(cnt)
    for _ in range(cnt):
        print(1, end=' ')
    print()

Submission status: Wrong Answer

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

def main():
    N = int(input())
    b = list(map(int, input().split()))
    ans = []
    for i in range(1,N+1):
        j = i
        a = 0
        while j <=N: a, j = a^b[j-1], j+i
        if a: ans.append(i)
    print(len(ans))
    print(*ans)
    

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys

def div(n):
    if n == 1: return [1]
    d = []
    for k in range(2, n):
        if k ** 2 > n: break
        if n % k == 0:
            if k ** 2 == n: d.append(k)
            else: 
                d.append(k)
                d.append(n // k)
    d.sort()
    return d

def solve():
    input = sys.stdin.readline
    N = int(input())
    A = [int(a) for a in input().split()]
    SumB = [0] * N
    Ans = []
    count = 0

    for i in reversed(range(N)):
        if SumB[i] % 2 == A[i]: continue
        elif (SumB[i] + 1) % 2 == A[i]:
            Ans.append(i + 1)
            count += 1
            d = div(i + 1)
            for j in d: SumB[j - 1] += 1
        else:
            print(-1)
            break
    else: 
        Ans.sort()
        print(count)
        print(" ".join(map(str, Ans)))
        

    return 0
if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

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

for i in range(n,0,-1):
  sum=0
  for j in range(i+i,n,i):
    sum^=b[j]
  b[i]=sum^a[i]
ans=[]
for i in range(1,len(b)):
  if b[i]:
    ans.append(i)
print(len(ans))
print(*ans)

Submission status: Wrong Answer

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

ans = [0]*n
for i in range(n)[::-1]:
    tmp = 0
    for j in range(n//(i+1)):
        tmp += ans[(i+1)*(j+1)-1]
    if tmp%2 != a[i]:
        ans[i] += 1

print(n)
print(*ans)

Submission status: Wrong Answer

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

index = N // 2
count1 = 0

for i in range(index,N):
    b[i] = a[i]
    if a[i] == 1:
        count1 += 1

count = 0

for i in range(index):

    for j in range(index-i-1+(index-i),N,index-i):
        count += a[j]

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

    count = 0

while len(b) - 1 >= 0:
    if b[len(b)-1] == 0:
        b.pop(len(b)-1)
    else:
        break

print(count1)
if count1 != 0:
    for i in range(len(b)):
        print(b[i],end=' ')

    print()

Submission status: Wrong Answer

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

index = N // 2

for i in range(index,N):
    b[i] = a[i]

count = 0

for i in range(index):

    for j in range(index-i-1+(index-i),N,index-i):
        count += a[j]

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

    count = 0

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

print(count)

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

print()

Submission status: Wrong Answer

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

B=[0]*(n+1)
C,cnt=[],0
for i in range(1,n+1)[::-1]:
    sum_list=sum([B[j] for j in range(1,n+1,i)])
    if sum_list%2!=A[i-1]:
        B[i]=1
        cnt +=1
        C.append(i)

print(cnt)
print(*C[::-1])

Submission status: Wrong Answer

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

B=[0]*(n+1)
for i in range(1,n+1)[::-1]:
    sum_list=sum([B[j] for j in range(1,n+1,i)])
    if sum_list%2!=A[i]:
        B[i]=1

C=[B[i] for i in range(1,n+1) if B[i]==1]
print(len(C))
print(*C)

Submission status: Wrong Answer

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

'''
A=[]
B=[]
for i in range():
    a, b = map(int, input().split())
    A.append(a)a
    B.append(b)'''


def sol(n,a):
    ans = [0]*n
    cnt = 0
    for i in range(n)[::-1]:
        aa = 0
        s=i+1
        while s <= n:
            aa += ans[s-1]
            s+=s

        if a[i] == (aa%2):
            continue
        else:
            ans[i]+=1
            cnt += 1
    if sum(ans)%2!=a[0]:
        ans[0]=1
    return ans,cnt
    
def main():
    import sys
    input = sys.stdin.readline
    n = int(input())
    a = list(map(int, input().split()))
    ans, cnt = sol(n,a)
    print(str(cnt))
    ansr = []
    for i in range(n):
        if ans[i]==1:
            ansr.append(i+1)
    print(' '.join(map(str, ansr)))

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

'''
A=[]
B=[]
for i in range():
    a, b = map(int, input().split())
    A.append(a)a
    B.append(b)'''


def sol(n,a):
    ans = [0]*n
    cnt = 0
    for i in range(n)[::-1]:
        aa = 0
        s=i+1
        while s <= n:
            aa += ans[s-1]
            s+=s

        if a[i] == (aa%2):
            continue
        else:
            ans[i]+=1
            cnt += 1
        if sum(ans)%2!=a[0]:
            ans[0]=1
    return ans,cnt
    
def main():
    import sys
    input = sys.stdin.readline
    n = int(input())
    a = list(map(int, input().split()))
    ans, cnt = sol(n,a)
    print(str(cnt))
    ansr = []
    for i in range(n):
        if ans[i]==1:
            ansr.append(i+1)
    print(' '.join(map(str, ansr)))

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
from sys import stdin

N = int(stdin.readline())
a = list(map(int, stdin.readline().split()))
A = [0] + a
B = [0]*(N+1)
putBall = []

for i in range(N, 0, -1):
    cnt = 1
    multiple = i
    tmp = 0
    while multiple <= N:
        tmp += B[multiple]
        cnt += 1
        multiple *= cnt
    if tmp%2 != A[i]:
        B[i] = 1
        putBall.append("%d" % i)

print(sum(B))
print(*putBall)

Submission status: Wrong Answer

Solution code:
from sys import stdin

N = int(stdin.readline())
a = list(map(int, stdin.readline().split()))
A = [0] + a
B = [0]*(N+1)
putBall = []

for i in range(N, 0, -1):
    cnt = 1
    multiple = i
    tmp = 0
    while multiple <= N:
        tmp += B[multiple]
        cnt += 1
        multiple *= cnt
    B[i] = (tmp + A[i])%2
    if B[i] == 1:
        putBall.append("%d" % i)

print(sum(B))
print(*putBall)

Submission status: Wrong Answer

Solution code:
from sys import stdin

N = int(stdin.readline())
a = list(map(int, stdin.readline().split()))
A = [0] + a
B = [0]*(N+1)
putBall = []

for i in range(N, 0, -1):
    cnt = 1
    multiple = i
    tmp = 0
    while multiple <= N:
        tmp += B[multiple]
        cnt += 1
        multiple *= cnt
    if tmp%2 != A[i]:
        B[i] = 1
        putBall.append("%d" % i)

print(sum(B))
print(" ".join(putBall))

Submission status: Wrong Answer

Solution code:
from sys import stdin

N = int(stdin.readline())
a = list(map(int, stdin.readline().split()))
A = [0] + a
B = [0]*(N+1)
putBall = []

for i in range(N, 2, -1):
    cnt = 1
    multiple = i
    tmp = 0
    while multiple <= N:
        tmp += B[multiple]
        cnt += 1
        multiple *= cnt
    if tmp%2 != A[i]:
        B[i] = 1
        putBall.append("%d" % i)
print(sum(B))
print(" ".join(putBall))

Submission status: Wrong Answer

Solution code:
from sys import stdin

N = int(stdin.readline())
a = list(map(int, stdin.readline().split()))
A = [0] + a
B = [0]*(N+1)
putBall = []

for i in range(N-1, 0, -1):
    cnt = 1
    multiple = i
    tmp = 0
    while multiple <= N:
        tmp += B[multiple]
        cnt += 1
        multiple *= cnt
    if tmp%2 != A[i]:
        B[i] = 1
        putBall.append("%d" % i)
print(sum(B))
print(" ".join(putBall))

Submission status: Wrong Answer

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

i = n-1
while i >= 0:
    cnt = 0
    for j in range(1, n):
        if (i+1) * j - 1  >= n:
            break
        cnt += ans[(i+1)*j-1]
    if cnt % 2 != a[i]:
        ans[i] = 1
    i -= 1
    #print(cnt)
print(ans.count(1))
for i in range(n):
    if ans[i] == 1:
        print(i+1)

Submission status: Wrong Answer

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

i = n
while i > 0:
    cnt = 0
    for j in range(1, n):
        if i * j  >= n:
            break
        cnt += ans[i*j]
    if cnt % 2 != a[i-1]:
        ans[i] = 1
    i -= 1
    #print(cnt)
print(ans.count(1))
for i in range(1,n+1):
    if ans[i] == 1:
        print(i)

Submission status: Wrong Answer

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

i = n
while i > 0:
    cnt = 0
    for j in range(1, n):
        if i * j  > n:
            break
        cnt += ans[i*j]
    if cnt % 2 != a[i-1]:
        ans[i] = 1
    i -= 1
    #print(cnt)
print(ans.count(1))
for i in range(n+1):
    if ans[i] == 1:
        print(i)

Submission status: Wrong Answer

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

i = n
while i > 0:
    cnt = 0
    for j in range(1, n):
        if i * j  > n:
            break
        cnt += ans[i*j]
    if cnt % 2 != a[i-1]:
        ans[i] = 1
    i -= 1
    #print(cnt)
print(ans.count(1))
for i in range(n):
    if ans[i] == 1:
        print(i)

Submission status: Wrong Answer

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

i = n
while i > 0:
    cnt = 0
    for j in range(1, n):
        if i * j  >= n:
            break
        cnt += ans[i*j]
    if cnt % 2 != a[i-1]:
        ans[i] = 1
    i -= 1
    #print(cnt)
print(ans.count(1))
for i in range(n):
    if ans[i] == 1:
        print(i)

Submission status: Wrong Answer

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

i = n-1
while i >= 0:
    cnt = 0
    for j in range(1, n):
        if i * j >= n:
            break
        cnt += ans[i*j]
    if cnt % 2 != a[i]:
        ans[i] = 1
    i -= 1
print(ans.count(1))
for i in range(n):
    if ans[i] == 1:
        print(i+1)

Submission status: Wrong Answer

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

'''
A=[]
B=[]
for i in range():
    a, b = map(int, input().split())
    A.append(a)a
    B.append(b)'''


def sol(n,a):
    ans = [0]*n
    cnt = 0
    for i in range(n)[::-1]:
        aa = 0
        s=i+1
        while s <= n:
            aa += ans[s-1]
            s+=s

        if a[i] == (aa%2):
            continue
        else:
            ans[i]+=1
            cnt += 1
    return ans,cnt
    
def main():
    import sys
    input = sys.stdin.readline
    n = int(input())
    a = list(map(int, input().split()))
    ans, cnt = sol(n,a)
    print(str(cnt))
    ansr = []
    for i in range(n):
        if ans[i]==1:
            ansr.append(i+1)
    print(' '.join(map(str, ansr)))

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

'''
A=[]
B=[]
for i in range():
    a, b = map(int, input().split())
    A.append(a)a
    B.append(b)'''


def sol(n,a):
    ans = [0]*n
    cnt = 0
    for i in range(n//2,n)[::-1]:
        if a[i]==1:
            ans[i]=1
            cnt +=1
        else:
            ans[i]=0
    for i in range(n//2)[::-1]:
        aa = 0
        s=i+1
        while s <= n:
            aa += ans[s-1]
            s+=s

        if a[i] == (aa%2):
            continue
        else:
            ans[i]+=1
            cnt += 1
    return ans,cnt
    
def main():
    import sys
    input = sys.stdin.readline
    n = int(input())
    a = list(map(int, input().split()))
    ans, cnt = sol(n,a)
    print(str(cnt))
    ansr = []
    for i in range(n):
        if ans[i]==1:
            ansr.append(i+1)
    print(' '.join(map(str, ansr)))

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

'''
A=[]
B=[]
for i in range():
    a, b = map(int, input().split())
    A.append(a)a
    B.append(b)'''


def sol(n,a):
    ans = [0]*n
    cnt = 0
    for i in range(n//2,n)[::-1]:
        if a[i]==1:
            ans[i]=1
            cnt +=1
        else:
            ans[i]=0
    for i in range(n//2)[::-1]:
        aa = 0
        s=i+1
        while s <= n:
            aa += ans[s-1]
            s+=s

        if a[i] == (aa%2):
            continue
        else:
            ans[i]+=1
            cnt += 1
    return ans,cnt
    
def main():
    import sys
    input = sys.stdin.readline
    n = int(input())
    a = list(map(int, input().split()))
    ans, cnt = sol(n,a)
    print(str(cnt))
    for i in range(n):
        if ans[i]==1:
            print(str(i+1)+" ")

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

'''
A=[]
B=[]
for i in range():
    a, b = map(int, input().split())
    A.append(a)a
    B.append(b)'''


def sol(n,a):
    ans = [0]*n
    cnt = 0
    for i in range(n//2,n)[::-1]:
        if a[i]==1:
            ans[i]=1
            cnt +=1
        else:
            ans[i]=0
    for i in range(n//2)[::-1]:
        aa = 0
        s=i+1
        while s <= n:
            aa += ans[i]
            s+=s

        if a[i] == (aa%2):
            continue
        else:
            ans[i]+=1
            cnt += 1
    return ans,cnt
    
def main():
    import sys
    input = sys.stdin.readline
    n = int(input())
    a = list(map(int, input().split()))
    ans, cnt = sol(n,a)
    print(str(cnt))
    for i in range(n):
        if ans[i]==1:
            print(str(i+1)+" ")

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

'''
A=[]
B=[]
for i in range():
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)'''


def sol(n,a):
    ans = [0]*n
    cnt = 0
    for i in range(n//2,n)[::-1]:
        if a[i]==1:
            ans[i]=1
            cnt +=1
        else:
            ans[i]=0
    for i in range(n//2)[::-1]:
        aa = 0
        s=i+1
        while s < n:
            aa += ans[i]
            s+=s

        if a[i] == (aa%2):
            continue
        else:
            ans[i]+=1
            cnt += 1
    return ans,cnt
    
def main():
    import sys
    input = sys.stdin.readline
    n = int(input())
    a = list(map(int, input().split()))
    ans, cnt = sol(n,a)
    print(str(cnt))
    for i in range(n):
        if ans[i]==1:
            print(str(i+1)+" ")

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [0] + list(map(int, input().split())) + [0] * (n + 5)
b = []
idx = n - 1
while idx > 0:
    if a[idx] != a[idx * 2]: b.append(idx)
    idx -= 1
print(len(b))
print(*b)

Submission status: Wrong Answer

Solution code:

N = int(input())
Bn =  list(map(int,input().split(' ')))

output_list = []

for i in reversed(range(N)):
    current_sum = 0
    target_num = i+1
    target_num_idx = 0
    print('i',i)
    for j in range((N)//(target_num)):
        target_num_idx = target_num_idx + target_num
        current_sum += Bn[target_num_idx -1]
        print('j',j)
    if current_sum % 2 != Bn[i]:
        if Bn[i] == 1:
            Bn[i] = 0
        else:
            Bn[i] = 1
    if Bn[i] == 1:
        output_list.append(target_num)
print(len(output_list))
output_list.reverse()
print(' '.join(map(str,output_list)))

Submission status: Wrong Answer

Solution code:
import math
import copy
from copy import deepcopy
import sys
import fractions
import numpy as np
from functools import reduce
import statistics
import heapq

# input = sys.stdin.readline
# sys.setrecursionlimit(10**6)

# ===FUNCTION===

def getInputInt():
    inputNum = int(input())
    return inputNum


def getInputListInt():
    outputData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData


def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList


def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList


# ===CODE===

n = getInputInt()
data = getInputListInt()
l = len(data)

ans = []

for i in range(l-1, -1, -1):
    cnt = 0
    for j in ans:
        if j % (i+1) == 0:
            cnt+=1
    if data[i] != cnt % 2:
        ans.append(i+1)

if len(ans) == 0:
    print(0)
else:
    print(*ans, sep=" ")

Submission status: Wrong Answer

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

def divisors(n):
  for i in range(1, min(n + 1,int(n ** 0.5) + 2)):
    if n % i == 0:
      ball[i - 1] += 1
  if n > 2:
    ball[n - 1] += 1

for i in range(N - 1,-1,-1):
  if A[i] != (ball[i] % 2):
    divisors(i + 1)

if sum(ball) == 0:
  print(0)
else:
  ball = [i + 1 for i in range(N) if ball[i] >= 1]
  print(len(ball))
  print(*ball)

Submission status: Wrong Answer

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

def divisors(n):
  for i in range(1, min(n + 1,int(n ** 0.5) + 2)):
    if n % i == 0:
      ball[i - 1] += 1
  if n > 2:
    ball[n - 1] += 1

for i in range(N - 1,-1,-1):
  if A[i] != (ball[i] % 2):
    divisors(i + 1)

if sum(ball) == 0:
  print(0)
else:
  ball = [1 for i in ball if i >= 1]
  print(len(ball))
  print(*ball)

Submission status: Wrong Answer

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

def divisors(n):
  for i in range(1, min(n + 1,int(n ** 0.5) + 2)):
    if n % i == 0:
      ball[i - 1] += 1
  if n > 2:
    ball[n - 1] += 1

for i in range(N - 1,-1,-1):
  if A[i] != (ball[i] % 2):
    divisors(i + 1)

if sum(ball) == 0:
  print(0)
else:
  ball = [i for i in ball if i >= 1]
  print(len(ball))
  print(*ball)

Submission status: Wrong Answer

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

def divisors(n):
  for i in range(1, min(n + 1,int(n ** 0.5) + 2)):
    if n % i == 0:
      ball[i - 1] += 1
  if n > 2:
    ball[n - 1] += 1

for i in range(N - 1,-1,-1):
  if A[i] != (ball[i] % 2):
    divisors(i + 1)

if sum(ball) == 0:
  print(0)
else:
  M = sum(ball)
  ball = [i for i in ball if i >= 1]
  print(M)
  print(*ball)

Submission status: Wrong Answer

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

def divisors(n):
  for i in range(1, int(n ** 0.5) + 1):
    if n % i == 0:
      ball[i - 1] += 1
  ball[n - 1] += 1

for i in range(N - 1,-1,-1):
  if A[i] != (ball[i] % 2):
    divisors(i + 1)

if sum(ball) == 0:
  print(0)
else:
  M = sum(ball)
  ball = [i for i in ball if i >= 1]
  print(M)
  print(*ball)