#P16341. [科大国创杯初中组 2026] 乘积

    ID: 18423 远端评测题 1000ms 512MiB 尝试: 0 已通过: 0 显示难度入门 上传者: 标签>安徽枚举2026科创活动初中活动科大国创杯

[科大国创杯初中组 2026] 乘积

Background

Subtask 0 uses community testdata, and Subtask 1 uses official testdata.

Problem Description

Xiaokeke has a sequence of positive integers. He wants to know whether it is possible to find a consecutive segment in this sequence whose product is equal to a positive integer xx.

Input Format

The first line contains two positive integers n,xn, x, representing the length of the sequence and the target product.

The second line contains nn positive integers a1,,ana_1, \dots, a_n, representing Xiaokeke's sequence.

Output Format

If you cannot find a consecutive segment whose product equals xx, output -1.

Otherwise, output two numbers l,rl, r (lrl \le r) such that al×al+1××ar=xa_l \times a_{l+1} \times \dots \times a_r = x.

If there are multiple valid pairs (l,r)(l, r), output the one with the smallest ll. If the smallest ll is the same, output the one with the smallest rr.

5 24
1 2 3 4 5
1 4
5 9
1 2 3 4 5
-1

Hint

Other Sample Notes

  • Sample 3 ~ 4: See multiply/multiply*.in and multiply/multiply*.ans in the contestant directory.

Constraints

  • For 30%30\% of the data, n=2n = 2.
  • For another 30%30\% of the data, x=1x = 1.
  • For 100%100\% of the data, n100n \le 100, 1ai,x1041 \le a_i, x \le 10^4.

Translated by ChatGPT 5