当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

2206:Magic Multiplying Machine

Special Judge 特殊评判
题目描述
Well known Las-Vegas casino "Big Jo" has recently introduced the new playing machine, called Magic Multiplying Machine (MMM). MMM has N levers and one big red button. Each lever is marked with some integer number ranging from 1 to M, thus i-th lever is marked with number ai.
A player who wishes to play on MMM inserts a coin into a special slot. After that she chooses some levers and pulls them. After she has made her choice, she presses the big red button. MMM blinks all its lights, rings its bells, plays different tunes and after that declares whether player has won the game.
The algorithm for determining whether the player has won is the following. If the player has pulled some real subset S of {1, 2, . . .N} of levers, her score is the product of numbers that these levers are markedwith, taken modulo M (if the player has pulled no levers, her score is 1):
score =Πi∈Sai mod M

Player has won the game if her score is maximal possible for the given machine.
Given the description of some MMM determine which levers should be pulled to win the game.
输入解释
The first line of the input contains two integer numbers N and M (1 <= N <= 10 000, 2 <= M <= 1 000). The second line of the input file contains N integer numbers ranging from 1 to M -- a1, a2, . . . aN.
输出解释
On the first line of the output file print one integer number -- the score that should be obtained to win the game. On the second line print in ascending order the numbers of levers that should be pulled to obtain this score (levers are numbered starting from one).
If there are several solutions, output any one.
输入样例
4 6
1 2 3 4
输出样例
4
1 4
来自北京大学POJ的附加信息
Case time limit(单组数据时间限制) 2000MS

该题目是Virtual Judge题目,来自 北京大学POJ

源链接: POJ-2206

最后修改于 2020-10-29T06:26:35+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
5000 65536