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: Runtime Error

Solution code:
import numpy as np

N = int(input())
a = list(map(int, input().split()))
ans = list(np.zores(N))
ans2 = []
for i in range(N):
    p = N - 1 - i
    if a[p] != sum(ans[p::p + 1]) % 2:
        ans[p] = 1
        ans2.append(str(p + 1))
print(sum(ans))
print(" ".join(ans2))

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    N=int(input())
    A=[0]+list(map(int,input().split()))
    ans=[0]*(N+1)
    s=[0]*(N+1)

    for i in reversed(range(1,N+1)):
        cnt=0
        for j in range(i+i,N+1,i):
            cnt^=s[j]
        if (A[i]==1 and cnt!=1) or (A[i]==0 and cnt!=0): s[i]=1
    
    print(sum(s))
    for i in range(1,N + 1):
        if s[i]==1:
            print(s.index(i))






    

resolve()

Submission status: Runtime Error

Solution code:
import numpy as np

n = int(input())
A = np.array(list(int(input()) for i in range(n)))
A_max = np.array([max(A)]*n)
A_dif = A - A_max
for i in range(n):
    if A_dif[i]<0:
        print(A_max)
    else:
        A_copy = A.copy()
        A_del = np.delete(A_copy, i)
        print(max(A_del))

Submission status: Runtime Error

Solution code:
print(i)

Submission status: Runtime Error

Solution code:
N = int(input())
a = list(map(int, input().split()))
ans = [0] * N
for i in range(N):
    tmp = N - i
    kosuu = N // tmp
    if kosuu == 1:
        if a[tmp-1] == 1:
            ans[tmp-1] = 1
    else:
        for j in range(kosuu-1):
            sub_sum += ans[tmp * (j + 2) -1]
            if a[tmp-1] != sub_sum % 2:
                ans[tmp-1] = 1

print(sum(ans))
print(*ans)

Submission status: Runtime Error

Solution code:
n = int(input())
a = list(map(int, input().split()))
ans = [0] * n
for i in range(n - 1, -1, -1):
    if i + 1 > n // 2:
        ans[i] = a[i]
    else:
        cnt = 0
        for j in range(i, n, i + 1):
            if ans[j] == 1:
                cnt += 1
        #ans[i] = cnt % 2 + a[i]
        if cnt % 2 == a[i]:
            ans[i] = 0
        else:
            ans[i] = 1 
print(sum(s))
for i, j in enumerate(s):
    if j == 1:
        print(i + 1)

Submission status: Runtime Error

Solution code:
import sys

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


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

    return divisors


def main():
    N = int(input())
    A = list(map(int, input().split()))
    S = [0] * (N)
    B = []
    for i in range(N - 1, -1, -1):
        S[i] %= 2
        if A[i] != S[i]:
            S[i] += 1
            B.append(i + 1)
            ds = make_divisors(i + 1)
            for d in ds:
                S[d] += 1
        else:
            continue

    print(len(B))
    print(*B, sep=" ")


if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
n = int(input())
a = list(map(int, input().split()))
b = [0 for _ in range(n)]
ans = []
for i in range(n, 0, -1):
    if a[i-1] == 0:
        tmp = 0
        j = i * 2
        while j < n:
            # print(j)
            tmp += b[j-1]
            j += i
        if tmp % 2 == 0:
            b[i-1] = 0
        else:
            b[i-1] = 1
    else:
        tmp = 0
        j = i * 2
        while j < n:
            # print(j-1)
            tmp += b[j-1]
            j += i
        if tmp % 2 == 1:
            b[i-1] = 0
        else:
            b[i-1] = 1

for i in range(n):
    if b[i] % 2 != 0:
        # print(b[i]%2)
        ans.append(a[i+1])
# print(b)
print(len(ans))
for i in ans:
    print(i)

Submission status: Runtime Error

Solution code:
n=int(input())
v=list(map(int,input().strip().split()))
a=[0]*n
for i in range(n-1,-1,-1):
  c=0
  for j in range(i,n,i):
    c ^= a[j]
  if c != v[i]:
    a[i] = 1
ans = []
for i in range(n):
  if a[i]: ans.append(i+1)
print(len(ans))
print(*ans)

Submission status: Runtime Error

Solution code:
#include <iostream>

using namespace std;

int n, m;
int a[220000];
bool p[220000];

int main()
{
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  
  for (int i = n; i > 0; i--) {
    int sm = 0;
    for (int j = i; j <= n; j += i) {
      if (p[j]) sm++;
    }
    sm %= 2;
    if (a[i] != sm) {
      p[i] = true;
      m++;
    }
  }
  
  cout << m << endl;
  for (int i = 1; i <= n; i++) {
    if (p[i]) {
      cout << i << " ";
    }
  }
  return 0;
}

Submission status: Runtime Error

Solution code:
n = int(input())
a = [int(x) for x in input().split()]
ans = [0]*n

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

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

Submission status: Runtime Error

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

n=int(input())
a=list(map(int,input().split()))
b=[0]*n
if n==1:
    b=a
elif n==2:
    b[1]=a[1]
    b[0]=(a[0]-b[1])%2
elif n==3:
    b[1]=a[1]
    b[2]=a[2]
    b[0]=(a[0]-b[1]-b[2])%2
i=2
while n/i>=2:
    for k in range(n//i,n//(i-1)):
        j=2
        b[k]=a[k]
        while j*(k+1)-1<n:
            b[k]=(b[k]-b[j*(k+1)-1])%2
            j+=1
    i+=1
j=1
b[1]=a[1]
b[0]=a[0]
while j*1<n:
    if 1+j*2<n:
        b[1]=(b[1]-b[1+j*2])%2
    b[0]=(b[0]-b[j*1])%2
    j+=1
num=0
for i in range(n):
    if b[i]==1:
        print(i+1)
        num+=1
if num==0:
  print(0)

Submission status: Runtime Error

Solution code:
def box():
    n = int(input())
    a = list(map(int,input().split()))
    ans = []
    for i in range(n,1-1,-1):
        total = 0
        for k in range(n//i):
            total += a[(k+1)*i -1]
        if total%2 == a[i-1]:
            if total%2 == 1:
                ans = [i] + ans
        else:
            return -1
    return ans

ans = box()
if ans == -1:
    print(-1)
print(len(ans))
if len(ans)>0:
    print(*ans)

Submission status: Runtime Error

Solution code:
N = int(input())
boxes = [0] * (N + 1)
ans = tuple(n for n, digit in reversed(tuple(enumerate(map(int, input().split()), 1))) if (sum(d for d in boxes[n::n]) & 1 != digit and (boxes.__setitem__(n, 1) or 1)))
print(f"{len(ans)}\n", *ans)

Submission status: Runtime Error

Solution code:
n = int(input())
nums = [int(i) for i in input().split()]

box = [0] * (n + 1)
for i in range(1, n + 1)[::-1]:
    ball = nums[i - 1]
    t = i * 2
    while t <= n:
        ball ^= box[t - 1]
        t += i
    box[t - 1] = ball

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

Submission status: Runtime Error

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

res = [0] * N
for idx, ai in zip(np.arange(N-1, -1, -1), As[::-1]):
    oe = sum([res[i] for i in range(idx, N, idx+1)]) % 2#
    res[idx] = ai ^ oe

print(sum(res))
idxs = []
for i, val in enumerate(res):
    if val:
        idxs += [i + 1]
print(*idxs)

Submission status: Runtime Error

Solution code:
def check(n):
    num=int(n**0.5)
    l=[1]
    for i in range(2,num+1):
        if n%i==0:
            l.append(i)
            l.append(n//i)
    return l

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

box=[0]*n
cnt=0
ans=[0]*n
for i in range(n):
    if a[-(i+1)]==box[i]:continue
    cnt+=1
    ans[-(i+1)]=1
    box[i]=(box[i]+1)%2
    l=check(n-i)
    for j in l:
        box[j]=(box[j]+1)%2

print(cnt)
if cnt==0:exit()
for i in range(n):
    if ans[i]:
        print(i+1,end=' ')

Submission status: Runtime Error

Solution code:
def check(n):
    num=int(n**0.5)
    l=[]
    for i in range(1,num+1):
        if n%i==0:
            l.append(i)
            l.append(n//i)
    return l

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

box=[0]*n
cnt=0
ans=[0]*n
for i in range(n):
    if a[-(i+1)]==box[i]:continue
    cnt+=1
    ans[-(i+1)]=1
    box[i]=(box[i]+1)%2
    l=check(n-i)
    for j in l:
        box[j]=(box[j]+1)%2

print(cnt)
if cnt==0:exit()
for i in range(n):
    if ans[i]:
        print(i+1,end='')

Submission status: Runtime Error

Solution code:
def check(n):
    num=int(n**0.5)
    l=[]
    for i in range(1,num+1):
        if n%i==0:
            l.append(i)
            l.append(n//i)
    return l

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

box=[0]*n
cnt=0
for i in range(n):
    if a[-(i+1)]==box[i]:continue
    cnt+=1
    box[i]=(box[i]+1)%2
    l=check(n-i)
    for j in l:
        box[j]=(box[j]+1)%2

print(cnt)
if cnt==0:exit()
print(*box[::-1])

Submission status: Runtime Error

Solution code:
m = int(input())
num_list = list(map(int,input().split()))
ans_list = [0]*m
print_list = []
for i in range(m):
    if num_list[m-i-1] == 0:
        cnt = 0
        for j in range(2**10):
            if (j+1)*(m-i) > m:
                break
            else:
                cnt += ans_list[(m-i)*(j+2)-1]
        if cnt % 2 == 1:
            ans_list[m-i-1] = 1
            print_list.append(m-i)
    elif num_list[m-i-1] == 1:
        cnt = 0
        for j in range(2**10):
            if (j+1)*(m-i) > m:
                break
            else:
                cnt += ans_list[(m-i)*(j+2)-1]
        if cnt % 2 == 0:
            ans_list[m-i-1] = 1
            print_list.append(m-i)
            
if not print_list:
    print(0)
    
else:
    print(sum(ans_list))
    print(*print_list)

Submission status: Runtime Error

Solution code:
mod = 10**9 + 7
from collections import deque

def main():
    N = iip(False)
    A = iip(True)

    sum_ball = [0 for i in range(N)]
    result = []
    for i, need in reversed(list(enumerate(A))):
        #print(i, need)

        if sum_ball[i] == need:
            continue

        elif sum_ball[i] == need - 1:
            result.append(i+1)

            for j in range(1, int(i+1 ** 0.5) + 1):
                if (i+1) % j == 0:
                    sum_ball[j] += 1
                    sum_ball[j] %= 2

        else:
            print("-1")
            exit()

    print(len(result))
    split_print_space(result)

#####################################################ライブラリ集ここから

def split_print_space(s):
    print(" ".join([str(i) for i in s]))

def split_print_enter(s):
    print("\n".join([str(i) for i in s]))


def searchsorted(sorted_list, n, side):
    if side not in ["right", "left"]:
        raise Exception("sideはrightかleftで指定してください")

    l = 0
    r = len(sorted_list)

    if n > sorted_list[-1]:
        #print(sorted_list)
        return len(sorted_list)
    if n < sorted_list[0]:
        return 0

    while r-l > 1:
        x = (l+r)//2
        if sorted_list[x] > n:
            r = x
        elif sorted_list[x] < n:
            l = x
        else:
            if side == "left":
                r = x
            elif side == "right":
                l = x

    if side == "left":
        if sorted_list[l] == n:
            return r - 1
        else:
            return r

    if side == "right":
        if sorted_list[l] == n:
            return l + 1
        else:
            return l


def iip(listed):
    ret = [int(i) for i in input().split()]
    if len(ret) == 1 and not listed:
        return ret[0]
    return ret

def soinsuu_bunkai(n):
    ret = []
    for i in range(2, int(n**0.5)+1):
        while n % i == 0:
            n //= i
            ret.append(i)
        if i > n:
            break
    if n != 1:
        ret.append(n)
    return ret


def conbination(n, r, mod, test=False):
    if n <=0:
        return 0
    if r == 0:
        return 1
    if r < 0:
        return 0
    if r == 1:
        return n
    ret = 1
    for i in range(n-r+1, n+1):
        ret *= i
        ret = ret % mod

    bunbo = 1
    for i in range(1, r+1):
        bunbo *= i
        bunbo = bunbo % mod

    ret = (ret * inv(bunbo, mod)) % mod
    if test:
        #print(f"{n}C{r} = {ret}")
        pass
    return ret


def inv(n, mod):
    return power(n, mod-2)

def power(n, p):
    if p == 0:
        return 1
    if p % 2 == 0:
        return (power(n, p//2) ** 2) % mod
    if p % 2 == 1:
        return (n * power(n, p-1)) % mod


if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
mod = 10**9 + 7
from collections import deque

def main():
    N = iip(False)
    A = iip(True)

    sum_ball = [0 for i in range(N)]
    result = []
    for i, need in reversed(list(enumerate(A))):
        #print(i, need)

        if sum_ball[i] == need:
            continue
        elif sum_ball[i] == need - 1:
            result.append(i+1)

            for j in range(1, int(i+1 ** 0.5) + 1):
                if (i+1) % j == 0:
                    sum_ball[j] += 1

        else:
            print("-1")
            exit()

    print(len(result))
    split_print_space(result)

#####################################################ライブラリ集ここから

def split_print_space(s):
    print(" ".join([str(i) for i in s]))

def split_print_enter(s):
    print("\n".join([str(i) for i in s]))


def searchsorted(sorted_list, n, side):
    if side not in ["right", "left"]:
        raise Exception("sideはrightかleftで指定してください")

    l = 0
    r = len(sorted_list)

    if n > sorted_list[-1]:
        #print(sorted_list)
        return len(sorted_list)
    if n < sorted_list[0]:
        return 0

    while r-l > 1:
        x = (l+r)//2
        if sorted_list[x] > n:
            r = x
        elif sorted_list[x] < n:
            l = x
        else:
            if side == "left":
                r = x
            elif side == "right":
                l = x

    if side == "left":
        if sorted_list[l] == n:
            return r - 1
        else:
            return r

    if side == "right":
        if sorted_list[l] == n:
            return l + 1
        else:
            return l


def iip(listed):
    ret = [int(i) for i in input().split()]
    if len(ret) == 1 and not listed:
        return ret[0]
    return ret

def soinsuu_bunkai(n):
    ret = []
    for i in range(2, int(n**0.5)+1):
        while n % i == 0:
            n //= i
            ret.append(i)
        if i > n:
            break
    if n != 1:
        ret.append(n)
    return ret


def conbination(n, r, mod, test=False):
    if n <=0:
        return 0
    if r == 0:
        return 1
    if r < 0:
        return 0
    if r == 1:
        return n
    ret = 1
    for i in range(n-r+1, n+1):
        ret *= i
        ret = ret % mod

    bunbo = 1
    for i in range(1, r+1):
        bunbo *= i
        bunbo = bunbo % mod

    ret = (ret * inv(bunbo, mod)) % mod
    if test:
        #print(f"{n}C{r} = {ret}")
        pass
    return ret


def inv(n, mod):
    return power(n, mod-2)

def power(n, p):
    if p == 0:
        return 1
    if p % 2 == 0:
        return (power(n, p//2) ** 2) % mod
    if p % 2 == 1:
        return (n * power(n, p-1)) % mod


if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
#AGC018-A
if False:
    import fractions

    N,K=map(int,input().split())
    A=[int(i) for i in input().split()]
    MAX=max(A)
    GCD=A[0]
    for a in A:
        GCD=fractions.gcd(a,GCD)
    if K%GCD==0 and K<=MAX:
        print('POSSIBLE')
    else:
        print('IMPOSSIBLE')

#ABC134-D
if True:
    M=int(input())
    B=[int(i) for i in input().split()]
    fact=[[1] for i in range(M)]
    for i in range(2,M+1):
        k=2
        while k*i<=M:
            fact[k*i-1].append(i)
            k+=1
    # print(fact)
    ANS=[]
    PAL=[0 for i in range(M)]
    for i in reversed(range(M)):
        if 2*(i+1)>M:
            PAL[i]+=B[i]
            if B[i]==1:
                ANS.append(i+1)
        else:
            if PAL[i]!=B[i]:
                PAL[i]=(PAL[i]+1)%2
                ANS.append(i+1)
        for j in fact[i]:
                PAL[j]=(PAL[j]+PAL[i])%2
            
            
    print(len(ANS))
    print(' '.join(map(str,ANS)))

Submission status: Runtime Error

Solution code:
#AGC018-A
if False:
    import fractions

    N,K=map(int,input().split())
    A=[int(i) for i in input().split()]
    MAX=max(A)
    GCD=A[0]
    for a in A:
        GCD=fractions.gcd(a,GCD)
    if K%GCD==0 and K<=MAX:
        print('POSSIBLE')
    else:
        print('IMPOSSIBLE')

#ABC134-D
if True:
    M=int(input())
    B=[int(i) for i in input().split()]
    fact=[[1] for i in range(M)]
    for i in range(2,M+1):
        k=2
        while k*i<=M:
            fact[k*i-1].append(i)
            k+=1
    # print(fact)
    ANS=[]
    PAL=[0 for i in range(M)]
    for i in reversed(range(M)):
        if 2*(i+1)>M:
            PAL[i]+=B[i]
            if B[i]==1:
                ANS.append(i+1)
        else:
            if PAL[i]!=B[i]:
                PAL[i]+=1
                ANS.append(i+1)
        for j in fact[i]:
                PAL[j]=(PAL[j]+PAL[i])%2
            
            
    print(len(ANS))
    print(' '.join(map(str,ANS)))

Submission status: Runtime Error

Solution code:
#AGC018-A
if False:
    import fractions

    N,K=map(int,input().split())
    A=[int(i) for i in input().split()]
    MAX=max(A)
    GCD=A[0]
    for a in A:
        GCD=fractions.gcd(a,GCD)
    if K%GCD==0 and K<=MAX:
        print('POSSIBLE')
    else:
        print('IMPOSSIBLE')

#ABC134-D
if True:
    M=int(input())
    B=[int(i) for i in input().split()]
    fact=[[1] for i in range(M)]
    for i in range(2,M+1):
        k=2
        while k*i<=M:
            fact[k*i-1].append(i)
            k+=1
    # print(fact)
    ANS=[2 for i in range(M)]
    for i in reversed(range(M)):
        if (i+1)*2>M:
            ANS[i]=B[i]
            for j in fact[i]:
                ANS[j-1]+=ANS[i]
        else:
            if B[j]!=(ANS[j]%2):
                ANS[j]+=1
        # print(ANS)
    print(N)
    for ans in ANS:
        print(ans)

Submission status: Runtime Error

Solution code:
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby
    #from itertools import product
    from bisect import bisect_left,bisect_right
    import heapq
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

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

    def yakusuu(N):
        n = int(N**.5)+1
        res1 = []
        res2 = []
        for i in range(1, n):
            if N%i==0:
                res1.append(i)
                if N!=i**2:
                    res2.append(N//i)
        res2.reverse()
        return res1+res2

    for i in range(n-1, -1, -1):
        if (a[i]==1 and dp[i]==0) or (a[i]==0 and dp[i]==1):
            l = yakusuu(a[i])
            res.append(i+1)
            for j in l:
                dp[j] = (dp[j] + 1) % 2
        else:
            continue
    print(len(res))
    if len(res)>0:
        print(' '.join(map(str, res)))

if __name__ == '__main__':
    main()

Submission status: Runtime Error

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

print(len(c))
for i in range(len(c)):
  print(c[i]+1,end=' ')

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
n = int(input())
a = [int(i) for i in input().split()]

count = [0 for _ in range(n)]
for i in reversed(range(1, n + 1)):
    tmp = 0
    for j in range(i, n, i):
        tmp += a[j]
    if a[i-1] % 2 != tmp % 2:
        count[i] += 1
m = sum(count)
ans = []
for i in range(n):
    if count[i] == 1:
        ans.append(str(i))

print(m)
print(' '.join(ans))

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
n = int(input())
a = [int(i) for i in input().split()]

count = [0 for _ in range(n)]
for i in reversed(range(1, n + 1)):
    tmp = 0
    for j in range(i, n, i):
        if j % i == 0:
            tmp += a[j]
    if a[i-1] % 2 != tmp % 2:
        count[i] += 1
m = sum(count)
ans = []
for i in range(n):
    if count[i] == 1:
        ans.append(str(i))

print(m)
print(' '.join(ans))

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
n = int(input())
a = [int(i) for i in input().split()]

count = [0 for _ in range(n)]
for i in reversed(range(1, n + 1)):
    tmp = 0
    for j in range(i, n, i):
        if j % i == 0:
            tmp += a[j]
    if a[i-1] % 2 != tmp % 2:
        count[i] += 1
m = count.count(1)
ans = []
for i in range(n):
    if count[i] == 1:
        ans.append(str(i))

print(m)
print(' '.join(ans))

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
n = int(input())
a = [int(i) for i in input().split()]

count = [0 for _ in range(n)]
for i in reversed(range(1, n + 1)):
    tmp = 0
    for j in range(i, n):
        if j % 1 == 0:
            tmp += a[j]
    if a[i-1] % 2 != tmp % 2:
        count[i] += 1
m = count.count(1)
ans = []
for i in range(n):
    if count[i] == 1:
        ans.append(str(i))

print(m)
print(' '.join(ans))

Submission status: Runtime Error

Solution code:
import sys

def solve():
    input = sys.stdin.readline
    N = int(input())
    A = [int(a) for a in input().split()]
    Count = [0] * N
    In = []
    add = 0
    for i in reversed(range(N)):
        k = i + 1
        if A[i] != Count[i]:
            Count[i] = (Count[i] + 1) % 2
            In.append(i + 1)
            add += 1
            Count[1] = (Count[1] + 1) % 2
            for div in range(2, k):
                if div ** 2 > k: break
                if k % div == 0:
                    if div ** 2 == k: Count[div - 1] = (Count[div - 1] + 1) % 2
                    else:
                        Count[div - 1] = (Count[div - 1] + 1) % 2
                        Count[(k % div) - 1] = (Count[(k % div) - 1] + 1) % 2
    if Count[0] != A[0]: print(-1)
    else:
        print(add)
        print(" ".join(map(str, In)))

    return 0

if __name__ == "__main__":
    solve()

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
import sys

MOD = 2  # type: int


def solve(N: int, a: "List[int]"):
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    N = int(input())
    a = [int(s) for s in input().split()]
    b = [0]*N
    sum_box = 0
    index = 2

    for i in range(N-1,-1,-1):
        if (i+1) <= N//index:
            index += 1

        if sum(b[i::(N//index)]) % 2 != a[i]:
            b[i] = 1
            sum_box += 1
        
    print(sum_box)
    
    for i in range(N):
        if b[i] == 1:
            print(i+1)
    

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
N = map(int, input().split())
alist = list(map(int, input().split()))
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

balls_multiple = [0] * N
ans = []
for num in range(N-1, -1, -1):
    if balls_multiple[num] % 2 != alist[num]:
        ans.append(num+1)
        for div in make_divisors(num+1):
            balls_multiple[div-1] += 1
if ans:
    print(len(ans))
    print(*sorted(ans))
else:
    print(0)

Submission status: Runtime Error

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


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


divisor = []
for i in range(1, N + 1):
    divisor.append(make_divisors(i))
B = [0]*N
rs = [0]*N
for i in range(N - 1, -1, -1):
    if rs[i] != A[i]:
        B[i] = 1
        for j in divisor[i]:
            rs[j] = 1 - rs[j]

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

Submission status: Runtime Error

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+1):
        if i * j  > n+1:
            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: Runtime Error

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: Runtime Error

Solution code:
import math
import copy
from copy import deepcopy
import sys
import fractions
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(len(ans))
    print(*ans, sep=" ")

Submission status: Runtime Error

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-2, -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(len(ans))
    print(*ans, sep=" ")

Submission status: Runtime Error

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(len(ans))
    print(*ans, sep=" ")

Submission status: Runtime Error

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()).rstrip("\n")
    return inputNum


def getInputListInt():
    outputData = []
    inputData = input().split().rstrip("\n")
    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(len(ans))
    print(*ans, sep=" ")