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

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

n = 3
a_s =[1,0,0]

m = 0
ans = [0]*(n+1)
#ans = np.zeros(n+1).astype(int)


i=1
for i in range(n,0,-1):
    sum_num = 0
    for j in range(i,n+1,i):
        sum_num += ans[j]

    if((sum_num & 1) != a_s[i-1]):
        m += 1
        ans[i] = 1

print(m)
print(' '.join(map(str,ans[1:])))

Submission status: Wrong Answer

Solution code:
#import numpy as np

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

n = 3
a_s =[1,0,0]

ans = [0]*(n+1)
#ans = np.zeros(n+1).astype(int)


i=1
for i in range(n,0,-1):
    sum_num = 0
    for j in range(i,n+1,i):
        sum_num += ans[j]

    if((sum_num & 1) != a_s[i-1]):
        ans[i] = 1

print(' '.join(map(str,ans[1:])))

Submission status: Wrong Answer

Solution code:
n,*a=map(int,open(0).read().split())
b=[0]*(n+1)
ans=[]
for i in range(n,0,-1):
    if sum (b[i::i])!=a[i-1]:
        b[i]=(b[i]+1)%2
        ans.append(i)
print(sum(b))
print(*ans)

Submission status: Wrong Answer

Solution code:
n,*a=map(int,open(0).read().split())
b=[0]*(n+1)
for i in range(n,0,-1):
    if sum (b[j] for j in range(i,n+1,i))!=a[i-1]:
        b[i]=(b[i]+1)%2
print(sum(b))
print(*b[1:])

Submission status: Wrong Answer

Solution code:
# 2019/10/04

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

for i in range(n):
    idx=n-i
    j=2
    cnt=0
    while idx*j<=n:
        cnt+=b[idx*j]
        j+=1
    cnt%=2
    if cnt==a[idx]:continue
    b[idx]=1
    
smb=sum(b)
print(smb)
for i in range(1,n+1):
    if b[i]:print(1,end=' ')
if smb:print()

Submission status: Wrong Answer

Solution code:
# 2019/10/04

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

for i in range(n):
    idx=n-i
    j=2
    cnt=0
    while idx*j<n:
        cnt+=b[idx*j]
        j+=1
    cnt%=2
    if cnt==a[idx]:continue

    b[idx]=1
if a==b:
    smb=sum(b)
    print(smb)
    for i in range(1,n+1):
        if b[i]:print(1,end=' ')
    if smb:print()
else:
    print(-1)

Submission status: Wrong Answer

Solution code:
N=int(input())
b=list(map(int,input().split()))
a=[0]*N
for i in range(N):
    z=i
    while z <= N-1:
        a[i] += b[z]
        z=(z+1)*2-1
s=sum(a)
print(s)
if s != 0:
    st = ''
    for i in a:
        st += str(i) + ' ' if i != 0 else ''
    print(st.rstrip())

Submission status: Wrong Answer

Solution code:
N=int(input())
b=list(map(int,input().split()))
a=[]
for i in reversed(range(N)):
    p=0
    while i <= N-1:
        p += b[i]
        i=(i+1)*2-1
    if p != 0:
        a.append(p)
s=sum(a)
print(s)
if s != 0:
    print(*a)

Submission status: Wrong Answer

Solution code:
N=int(input())
b=list(map(int,input().split()))
a=[]
for i in range(N):
    z = N-i-1
    p=0
    while z <= N-1:
        p += b[z]
        z=(z+1)*2-1
    if p != 0:
        a.append(p)
print(sum(a))
if sum(a) != 0:
    print(*a)

Submission status: Wrong Answer

Solution code:
N=int(input())
b=list(map(int,input().split()))
a=[0]*N
for i in range(N):
    z = N-i-1
    while z <= N-1:
        a[N-1-i] += b[z]
        z=(z+1)*2-1
print(sum(a))
if sum(a) != 0:
    s = ''
    for i in a:
        s += str(i) + ' ' if i != 0 else ''
    print(s.rstrip())

Submission status: Wrong Answer

Solution code:
N=int(input())
b=list(map(int,input().split()))
a=[0]*N
for i in range(N):
    z = N-i-1
    while z <= N-1:
        a[N-1-i] += b[z]
        z=(z+1)*2-1
print(sum(a))
print(*a)

Submission status: Wrong Answer

Solution code:
N = int(input())
pfactor = [-1] * (N + 1)
pfactor[0] = pfactor[1] = 1

for i in range(2, N + 1):
    if pfactor[i] == -1:
        pfactor[i] = i
        num = 2 * i
        while num <= N:
            pfactor[num] = i
            num += i

ans = []
balls = [0] * (N + 1)
A = [int(x) for x in input().split()]
for i in reversed(range(1, N+1)):
    if balls[i] != A[i-1]:
        ans.append(i)
        balls[i] ^= 1
    balls[i // pfactor[i]] ^= balls[i]

print(len(ans))
if ans:
    print(*ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
pfactor = [-1] * (N + 1)
pfactor[0] = pfactor[1] = 1

for i in range(2, N + 1):
    if pfactor == -1:
        pfactor[i] = i
        num = 2 * i
        while num <= N + 1:
            pfactor[num] = i
            num += i

ans = []
balls = [0] * (N + 1)
A = [int(x) for x in input().split()]
for i in reversed(range(1, N+1)):
    if balls[i] != A[i-1]:
        ans.append(i)
        balls[i] ^= 1
    balls[i // pfactor[i]] ^= balls[i]
print(len(ans))
if ans:
    print(*ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
pfactor = [-1] * (N + 1)
pfactor[0] = pfactor[1] = 1

for i in range(2, N + 1):
    if pfactor == -1:
        pfactor[i] = i
        num = 2 * i
        while num <= N + 1:
            pfactor[num] = i
            num += i

ans = []
balls = [0] * (N + 1)
A = [int(x) for x in input().split()]
for i in reversed(range(1, N+1)):
    if balls[i] != A[i-1]:
        ans.append(i)
        balls[i // pfactor[i]] ^= 1
print(len(ans))
if ans:
    print(*ans)

Submission status: Wrong Answer

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

for i in range(n-1, -1, -1):
    ms = sum(box[::i+1])
    if ms % 2 != a[i]:
        box[i] = 1
        ans.append(i+1)

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

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int,input().split()))
A=[0]+A
B=[0]*(N+1)
#print(A)

for i in range(N,0,-1):
  B[i]=A[i]
  if B[i]:
    for j in range(2,N//i+1):
      B[i*j] = 0 if B[i*j] else 1
  
#print(B)
C=[]
for i in range(1,N+1):
  if B[i]: C.append(i)
#print(C)

print(len(C))
if len(C): print(*C)

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int,input().split()))
A=[0]+A
B=[0]*(N+1)
#print(A)

for i in range(N,0,-1):
  B[i]=A[i]
  if B[i]:
    for j in range(2,N//i+1):
      B[i*j] = 0 if B[i*j] else 1
  
#print(B)
print(len(B)-1)
print(*B[1:])

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int,input().split()))
A=[0]+A
B=[0]*(N+1)
#print(A)

for i in range(N,0,-1):
  tmp=0
  for j in range(2,N//i+1):
    if B[i*j]: tmp+=1
  B[i]=(tmp+A[i])%2
  
#print(B)
print(len(B)-1)
print(*B[1:])

Submission status: Wrong Answer

Solution code:
import numpy as np
n = int(input())
a = list(map(int,input().split()))
ans = np.array(a)
k = 2
for i in reversed(range(1, n+1)):
    if n/k < i:
        for x in range(2, k):
            ans[i-1] += ans[x * i - 1]
        ans[i-1] = ans[i-1] % 2
    else:
        k += 1
        for x in range(2, k):
            ans[i-1] += ans[x * i - 1]
        ans[i-1] = ans[i-1] % 2

print(np.sum(ans))
for p in np.ndarray.flatten(np.argwhere(ans) + 1):
    print(p, end=' ')

Submission status: Wrong Answer

Solution code:
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())


def divisors(m: int):
    i = 1
    div = []
    while i * i <= m:
        if m % i == 0:
            div.append(i)
            div.append(m // i)
        i += 1

    return list(set(div))

n = ni()
a = list(li())
b = [0]*n

for i in range(n-1, -1, -1):
    if a[i] == 1:
        divs = divisors(i+1)
        for j in divs:
            b[j-1] += 1
            b[j-1] %= 2

print(sum(b))
ans = []
for i in range(n):
    if b[i]%2:
        ans.append(i+1)

if ans:
    print(*ans)

Submission status: Wrong Answer

Solution code:
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())


def divisors(m: int):
    i = 1
    div = []
    while i * i <= m:
        if m % i == 0:
            div.append(i)
            div.append(m // i)
        i += 1

    return list(set(div))

n = ni()
a = list(li())
b = [0]*n

for i in range(n-1, -1, -1):
    if a[i] == 1:
        divs = divisors(i+1)
        for j in divs:
            b[j-1] += 1

print(sum(b))
ans = []
for i in range(n):
    if b[i]%2:
        ans.append(i+1)

if ans:
    print(*ans)

Submission status: Wrong Answer

Solution code:
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n = ni()
a = list(li())
b = [0]*n

for i in range(n-1, -1, -1):
    if a[i] == 1:
        b[i] = 1

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

if ans:
    print(*ans)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce


INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


n = I()
L = LI()
A = [0] * n
total = 0
for i in range(n - 1, -1, -1):
    if L[i]:
        ret = 0
        for j in range(i * 2, n):
            ret += A[j]
        if L[i] != ret % 2:
            A[i] = 1
            total += 1


print(total)
for k in range(n):
    if A[k]:
        print(k + 1)

Submission status: Wrong Answer

Solution code:
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

N = int(input())
A = list(map(int, input().split()))
counts = [0] * N
ball_counts = 0
balls = []
for i in range(N-1, -1, -1):
    if counts[i] % 2 != A[i]:
        ball_counts += 1
        balls.append(i+1)
        divisors = make_divisors(i)
        for j in divisors:
            counts[j-1] += 1
print(ball_counts)
if ball_counts > 0:
    print(*balls)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
N=int(input())
A=list(map(int,input().split()))
l=[0]*N
count=0
ans=[]

for index in range(N)[::-1]:
    n=N//(index+1)
    while n>1:
        l[index]=l[(index+1)*n-1]^l[index]
        n-=1
        
    if A[index]&l[index]==1:
        print(-1)
        exit()
    elif A[index]^l[index]==1:
        l[index]=l[index]^1
    else:
        continue

for i in range(len(l)):
    if l[i]==1:
        count+=1
        ans.append(i+1)
print(count)
print(*ans)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
N=int(input())
A=list(map(int,input().split()))
l=[0]*N
count=0
ans=[]

for index in range(N)[::-1]:
    n=N//(index+1)
    while n>1:
        l[index]=l[(index+1)*n-1]^l[index]
        n-=1
        
    if A[index]&l[index]==1:
        print(index)
        print(-1)
        exit()
    elif A[index]^l[index]==1:#ここが違うかも
        l[index]=l[index]^1
    else:
        continue

for i in range(len(l)):
    if l[i]==1:
        count+=1
        ans.append(i+1)
print(count)
print(*ans)#0011が最適化されてない

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
N=int(input())
A=list(map(int,input().split()))
l=[0]*N
count=0
ans=[]

for index in range(N)[::-1]:
    n=2
    while N>=(index+1)*n:
        l[index]=l[(index+1)*n-1]^l[index]
        n+=1
        
    if A[index]&l[index]==1:
        print(index)
        print(-1)
        exit()
    elif A[index]==1:#ここが違うかも"""or l[index]==1"""
        l[index]=1
        count+=1
        ans.append(index+1)
    else:
        continue
print(count)
print(*ans[::-1])#0011が最適化されてない

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
N=int(input())
A=list(map(int,input().split()))
l=[0]*N
count=0
ans=[]

for index in range(N)[::-1]:
    n=2
    while N>=(index+1)*n:
        l[index]=l[(index+1)*n-1]^l[index]
        n+=1
        
    if A[index]&l[index]==1:
        print(-1)
        exit()
    elif A[index]==1 and A[index]^l[index]==1:#ここが違うかも
        l[index]=1
        count+=1
        ans.append(index+1)
    else:
        continue
print(count)
print(*ans[::-1])

Submission status: Wrong Answer

Solution code:
def main():
    n = int(input())
    A = list(map(int, input().split()))
 
    filled = [0]*(n+1)
    ans = []
    for i in range(n-1, -1, -1):
        if sum(filled[::i+1][1:]) % 2 != A[i]:
            filled[i+1] = 1
            ans.append(i+1)
    print(len(ans))
    print(' '.join(map(str, ans)))

Submission status: Wrong Answer

Solution code:
import math
def main():

    N = int(input())
    A = list(map(int, input().split()))
    d = dict()
    for i in range(1, N+1):
        d[i] = -1


    for i in range(N):
        p = helper(i+1)
        count = 0
        for j in p[:-1]:
            count += d[j]
        if(count % 2 == A[i]): d[p[-1]] = 0
        else: d[p[-1]] = 1

    ans = []
    for i in range(N):
        if d[i+1] ==  1: ans.append(i+1)
    return ans

def helper(n):
    p = []
    for i in range(1, int(math.sqrt(n))+1):
        if n % i == 0:
            p.append(i)
            if(n // i != i): p.append(n//i)
    return sorted(p)

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

Submission status: Wrong Answer

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

anslist = [0] * (N-1)
anslist.insert(0, 1)

# print(anslist)
# print('A:', A)
# print('A[0]:', A[0])

if(A[0] == 0):
    print(0)
else:
    print(1)
    print(1)
    # print(" ".join(map(str, anslist)))

Submission status: Wrong Answer

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

anslist = [0] * (N-1)
anslist.insert(0, 1)
# anslist.pop()


if(A[0] == 0):
    print(0)
else:
    print(1)
    print(" ".join(map(str, anslist)))

Submission status: Wrong Answer

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

print(N)
print(A)

anslist = [0] * N
# anslist.pop()


if(A[0] == 0):
    print(0)
else:
    print(1)
    print(" ".join(map(str, anslist)))

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
N=int(input())
A=list(map(int,input().split()))
l=[0]*N
count=0
ans=[]

for index in range(N)[::-1]:
    n=2
    while N>=(index+1)*n:
        l[index]=l[(index+1)*n-1]^l[index]
        n+=1
        
    if A[index]&l[index]==1:
        print(-1)
        exit()
    elif A[index]^l[index]==1:
        l[index]=1
        count+=1
        ans.append(index+1)
    else:
        continue
print(count)
print(*ans[::-1])

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
M=int(input())
B=list(map(int,input().split()))
l=[0]*M

for i in range(1,-int(-M**0.5//1)+1):
    print(i)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
B = [0 for i in range(N)]

out = []
for i in range(N, 0, -1):
    a = A[i - 1]
    q = N // i
    count = 0
    
    for j in range(2, q+1):
        if B[i * j - 1] == 1:
            count += 1
    
    r = count % 2
    
    if a == 0:
        if r == 1:
            B[i - 1] == 1
            out.append(i)
        else:
            B[i-1] = 0
    else:
        if r == 1:
            B[i - 1] = 0
        else:
            B[i - 1] = 1
            out.append(i)
g = sum(B)
print(g)
    
if g != 0:
    print(*out)

Submission status: Wrong Answer

Solution code:
n=int(input())
a= list(map(int, input().split()))
num=[0 for _ in range(n)]
li=[]

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

for i in range(n-1,-1,-1):
    if sum(num[i::i+1])%2!=a[i]:
        li.append(i+1)
        for j in make_divisors(i+1):
            num[j-1]+=1
print(len(li))
print(" ".join(map(str,li)))

Submission status: Wrong Answer

Solution code:
n=int(input())
lists=list(map(int,input().split()))
lists.insert(0,0)
anslists=[0]*(n+1)
for j in range(n,0,-1):
# j=n,n-1,.......,2,1という感じ
    numbers=n//j
    if numbers==1:
        anslists[j]=lists[j]
    else:
        check=0
        for i in range(2,numbers+1):
            check+=lists[i*j]
        if (lists[j]-check)%2==0:
            anslists[j]=lists[j]
        if (lists[j]-check)%2!=0:
            if lists[j]==0:
                anslists[j]=1
            if lists[j]==1:
                anslists[j]=0
Anslist=[]
printA=0

for k in range(n):
    if anslists[k]==1:
        printA+=1
        Anslist.append(k+1)
print(printA)
print(*Anslist)

Submission status: Wrong Answer

Solution code:
n=int(input())
lists=list(map(int,input().split()))
anslists=[0]*(n)
for j in range(n-1,-1,-1):
    #j+1がインデックスの番号を指す
    #例えばn=4の時　jは3210を返す j+1= 4 3 2 1
    check=0
    numbers=n//(j+1)
    for i in range(numbers):
        check+=lists[(j+1)*(i+1)-1]
    if (lists[j]-check)%2==0:
        anslists[j]=lists[j]
    if (lists[j]-check)%2!=0:
        if lists[j]==0:
            anslists[j]=1
        if lists[j]==1:
            anslists[j]=0
Anslist=[]
printA=0
for k in range(n):
    if anslists[k]==1:
        printA+=1
        Anslist.append(k+1)
print(printA)
print(*Anslist)

Submission status: Wrong Answer

Solution code:
n=int(input())
lists=list(map(int,input().split()))
anslists=[0]*(n)
 
for i in range(n-1,-1,-1):
 # i= n-1, n-2......1,0
 #左からi+1番目に着いて調べる
    number=n//(i+1)
    if number==1:
          anslists[i]=lists[i]
    else:
        cnt=0
        check=0
        while cnt<=number-1:
           check+=lists[i+cnt*(i+1)]
           cnt+=1
        nums=check-lists[i]
        if nums%2==0:
           anslists[i]=lists[i]
        elif nums%2!=0:
           if lists[i]==0:
               anslists[i]=1
           if lists[i]==1:
               anslists[i]=0
Anscnt=0
Anslist=[]
for j in range(n):
    if anslists[j]==1:
        Anslist.append(j+1)
        Anscnt+=1
print(Anscnt)
print(*Anslist)

Submission status: Wrong Answer

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

for i in range(n-1,-1,-1):
 # i= n-1, n-2......1,0
 #左からi+1番目に着いて調べる
    number=n//(i+1)
    if number==1:
          anslists[i]=lists[i]
    else:
        cnt=0
        check=0
        while cnt<=number-1:
           check+=anslists[i+cnt*(i+1)]
           cnt+=1
        nums=check-lists[i]
        if nums%2==0:
           anslists[i]=lists[i]
        elif nums%2!=0:
           if lists[i]==0:
               anslists[i]=1
           if lists[i]==1:
               anslists[i]=0
Anscnt=0
Anslist=[]
for j in range(n):
    if anslists[j]==1:
        Anslist.append(j+1)
        Anscnt+=1
print(Anscnt)
print(*Anslist)

Submission status: Wrong Answer

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

for i in range(n-1,-1,-1):
 # i= n-1, n-2......1,0
 #左からi+1番目に着いて調べる
    number=n//(i+1)
    if number==1:
          anslists[i]=lists[i]
    else:
        cnt=0
        check=0
        while cnt<=number-1:
           check+=anslists[i+cnt*(i+1)]
           cnt+=1
        nums=check-lists[i]
        if nums%2==0:
           anslists[i]=lists[i]
        elif nums%2!=0:
           if lists[i]==0:
               anslists[i]=1
           if lists[i]==1:
               anslists[i]=0
           
print(len(anslists))         
print(*anslists)

Submission status: Wrong Answer

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

for i in range(n-1,-1,-1):
 # i= n-1, n-2......1,0
 #左からi+1番目に着いて調べる
    number=n//(i+1)
    if number==1:
          anslists[i]=lists[i]
    else:
        cnt=0
        check=0
        while cnt<=number-1:
           check+=anslists[i+cnt*(i+1)]
           cnt+=1
        nums=check-lists[i]
        if nums%2==0:
           anslists[i]=lists[i]
        elif nums%2!=0:
           if lists[i]==0:
               anslists[i]=1
           if lists[i]==1:
               anslists[i]=0
           
print(len(anslists))         
print(*anslists)

Submission status: Wrong Answer

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

for i in range(n-1,-1,-1):
 # i= n-1, n-2......1,0
 #左からi+1番目に着いて調べる
    number=n//(i+1)
    if number==1:
          anslists[i]=lists[i]
    else:
        cnt=0
        check=0
        while cnt<=number-1:
           check+=anslists[i+cnt*(i+1)]
           cnt+=1
        nums=check-lists[i]
        if nums%2==0:
           anslists[i]=lists[i]
        elif nums%2!=0:
           if lists[i]==0:
               anslists[i]=1
           if lists[i]==1:
               anslists[i]=0
           
           
print(*anslists)

Submission status: Wrong Answer

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

for i in range(n-1,-1,-1):
    cnt=0
    check=0
 # i= n-1, n-2......1,0
 #左からi+1番目に着いて調べる
    number=n//(i+1)
    if number==1:
          anslists[i]=lists[i]
    else:
        while cnt<=number-1:
           check+=anslists[i+cnt*(i+1)]
        nums=check-lists[i]
        if nums%2==0:
           anslists[i]=lists[i]
        elif nums%2!=0:
           if lists[i]==0:
               anslists[i]=1
           if lists[i]==1:
               anslists[i]=0
           
           
print(*anslists)

Submission status: Wrong Answer

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

ans = []
cur = 0
for i in range(n,0,-1):
	# print("i",i)
	j = i
	cur = A[i-1]
	k = 1
	while j*k <= n:
		# print("j*k",j,k)
		cur += A[j*k-1]
		k += 1
	if cur % 2 != A[i-1]:
		ans.append(i)
		A[i-1] = 1
	# print(A,ans)
print(len(ans))
if ans:
	print(*ans[::-1])

Submission status: Wrong Answer

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

ans = []
cur = 0
for i in range(n,0,-1):
	# print("i",i)
	j = i
	cur = A[i-1]
	k = 1
	while j*k <= n:
		# print("j",j)
		cur += A[j-1]
		k += 1
	if cur % 2 != A[i-1]:
		ans.append(i)
		A[i-1] = 1
	# print(A,ans)
print(len(ans))
if ans:
	print(*ans[::-1])

Submission status: Wrong Answer

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

ans = []
cur = 0
for i in range(n,0,-1):
	# print("i",i)
	j = i
	cur = A[i-1]
	k = 1
	while j*k <= n:
		# print("j",j)
		cur += A[j-1]
		k += 1
	if cur % 2 != A[i-1]:
		ans.append(i)
		A[i-1] = 1
	# print(A,ans)
print(len(ans))
if ans:
	print(*ans)

Submission status: Wrong Answer

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

ans = []
cur = 0
for i in range(n,0,-1):
	# print("i",i)
	j = i
	cur = A[i-1]
	k = 1
	while j*k <= n:
		# print("j",j)
		cur += A[j-1]
		k += 1
	if cur % 2 != A[i-1]:
		ans.append(1)
		A[i-1] = 1
	# print(A,ans)
print(len(ans))
if ans:
	print(*ans)

Submission status: Wrong Answer

Solution code:

N = int(input())

#Aiは 1 or 0
#i の倍数が書かれ箱に入っているボールの個数の和が偶数か奇数か
A = list(map(int,input().split()))
B = [0] * N

#後ろからボールを入れるかいれないか決めていく
#後ろが決まっていれば前はその倍数の和がいくらであるかで求められる

for i in range(N-1,0,-1):
    #自分より後ろの倍数の総和をカウント
    count = 0
    for j in range(i,N,i):
        if B[j] == 1:
            count += 1
    #ボールの総和が A[i]と異なるならボールを入れる
    if (count % 2) == A[i]:
        B[i] = 0
    else:
        B[i] = 1

count = 0
for j in range(N):
    if B[j] == 1:
        count += 1
    if (count % 2) == A[0]:
        B[0] = 0
    else:
        B[0] = 1
print(sum(B))

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

print('\n')

Submission status: Wrong Answer

Solution code:
N =int(input())
a_list = list(map(int, ("0 " + input()).split()))

count = 0
in_list = []
for index in reversed(range(len(a_list))):
    if index == 0:
        break
    upper_index_keisuu = 2
    upper_sum = 0
    while True:
        if index * upper_index_keisuu > len(a_list)-1:
            break
        upper_sum += a_list[index * upper_index_keisuu]
        upper_sum %= 2
        upper_index_keisuu += 1

    if upper_sum != a_list[index]:
        count += 1
        in_list.append(index)


print(count)

if count > 0:
    ret_str = ""
    for add in in_list:
        ret_str += str(add) + " "
    print(ret_str)

Submission status: Wrong Answer

Solution code:
N =int(input())
a_list = list(map(int, ("0 " + input()).split()))

count = 0
in_list = []
for index in reversed(range(len(a_list))):
    if index == 0:
        break
    upper_index_keisuu = 2
    upper_sum = 0
    while True:
        if index * upper_index_keisuu > len(a_list)-1:
            break
        upper_sum += a_list[index * upper_index_keisuu]
        upper_sum %= 2
        upper_index_keisuu += 1
        break
    if upper_sum != a_list[index]:
        count += 1
        in_list.append(index)


print(count)

if count > 0:
    ret_str = ""
    for add in in_list:
        ret_str += str(add) + " "
    print(ret_str)

Submission status: Wrong Answer

Solution code:
N =int(input())
a_list = list(map(int, ("0 " + input()).split()))

count = 0
in_list = []
for index in reversed(range(len(a_list))):
    if index == 0:
        break
    upper_index_keisuu = 2
    upper_sum = 0
    while True:
        if index * upper_index_keisuu > len(a_list)-1:
            break
        upper_sum += a_list[index * upper_index_keisuu]
        upper_sum %= 2
        upper_index_keisuu += 1
        break
    if upper_sum != a_list[index]:
        count += 1
        in_list.append(index)

if count == 0:
    ret_str = "-1"
else:
    ret_str = ""
    for add in in_list:
        ret_str += str(add) + " "
print(count)
print(ret_str)

Submission status: Wrong Answer

Solution code:
N =int(input())
a_list = list(map(int, ("0 " + input()).split()))

count = 0
in_list = []
for index in reversed(range(len(a_list))):
    if index == 0:
        break
    upper_index_keisuu = 2
    upper_sum = 0
    while True:
        if index * upper_index_keisuu > len(a_list)-1:
            break
        upper_sum += a_list[index * upper_index_keisuu]
        upper_sum %= 2
        upper_index_keisuu += 1
        break
    if upper_sum != a_list[index]:
        count += 1
        in_list.append(index)
print(count)
ret_str = ""
for add in in_list:
    ret_str += str(add) + " "
print(ret_str)

Submission status: Wrong Answer

Solution code:
s=input()[::-1]

amari=[[(10**i)*x%13 for x in range(10)] for i in range(6)]
dp=[1]+[0]*12
new_dp=[0]*13

mod=10**9+7

for id,char in enumerate(s):
    new_dp=[0]*13
    if char!='?':
        for i in range(13):
            new_i=(i+amari[id%6][int(char)])%13
            new_dp[new_i]+=dp[i]
        dp=new_dp
    else:
        for i in range(13):
            for j in range(10):
                new_i=(i+amari[id%6][j])%13
                new_dp[new_i]+=dp[i]
        dp=[x%mod for x in new_dp]
print(dp[5])

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
A.insert(0, 0)
B = [0] * (N + 1)
for i in range(1, N + 1):
    sum_val = 0
    for j in range(i*2, N + 1, i):
        sum_val ^= B[j]
    B[i] = sum_val ^ A[i]

ans = [str(idx) for idx, val in enumerate(B) if val == 1]
print(len(ans))
print(" ".join(ans))

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
A.insert(0, 0)
B = [0] * (N + 1)
for i in range(1, N + 1):
    sum_val = 0
    for j in range(i*2, N + 1, i):
        sum_val ^= B[j]
    B[i] = sum_val ^ A[i]

ans = [str(idx) for idx, val in enumerate(B) if val == 1]
print(len(ans))
print("".join(ans))

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
A.insert(0, 0)
B = [0] * (N + 1)
for i in range(1, N + 1):
    sum_val = 0
    for j in range(i*2, N + 1, i):
        sum_val ^= B[j]
    B[i] = sum_val ^ A[i]

ans = ["1" for val in B if val == 1]
print(len(ans))
print("".join(ans))

Submission status: Wrong Answer

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

count = 0
for i in reversed(range(N)):
    idx = i * 2 + 1
    if idx > N - 1:
        B[i] = A[i]
    else:
        B[i] = (B[idx] + A[i]) % 2
    
    count += B[i]

print(count)
ans = []
for idx, val in enumerate(B):
    if val == 1:
        ans.append(str(idx + 1))
print("".join(ans))

Submission status: Wrong Answer

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

for i in range(n, 0, -1):
    if i > n//2:
        if a[i-1] == 1:
            box[i-1] += 1
    elif i == 1:
        if a[0] != (sum(box) % 2):
            box[0] += 1
    elif a[i-1] != (sum(box[i-1:: i-1]) % 2):
        box[i-1] += 1

for i in range(n):
    if box[i] == 1:
        m += 1
        b.append(i+1)

print(m)
for x in b:
    print(x, end=' ')