CF703E.Mishka and Divisors

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

After playing with her beautiful array, Mishka decided to learn some math. After learning how to multiply, divide and what is divisibility, she is now interested in solving the following problem.

You are given integer kk and array a1,a2,...,ana_{1},a_{2},...,a_{n} of nn integers. You are to find non-empty subsequence of array elements such that the product of its elements is divisible by kk and it contains minimum possible number of elements.

Formally, you are to find a sequence of indices 1<=i_{1}<i_{2}<...<i_{m}<=n such that is divisible by kk while mm is minimum possible among all such variants.

If there are more than one such subsequences, you should choose one among them, such that sum of its elements is minimum possible.

Mishka quickly solved this problem. Will you do so?

输入格式

The first line of the input contains two integers nn and kk ( 1<=n<=10001<=n<=1000 , 1<=k<=10121<=k<=10^{12} ).

The second line of the input contains nn integers a1,a2,...,ana_{1},a_{2},...,a_{n} ( 1<=ai<=10121<=a_{i}<=10^{12} ) — array elements.

输出格式

Print single positive integer mm in the first line — the number of elements in desired sequence.

In the second line print mm distinct integers — the sequence of indices of given array elements, which should be taken into the desired sequence.

If there are more than one such subsequence (e.g. subsequence of minimum possible number of elements and with minimum possible sum of elements), you can print any of them.

If there are no such subsequences, print 1-1 in the only line.

输入输出样例

  • 输入#1

    5 60
    2 4 6 5 2
    

    输出#1

    3
    4 3 1 
首页