QOJ.ac

QOJ

时间限制: 2 s 内存限制: 512 MB 总分: 70

#13426. 彩票

统计

Vedran 爷爷正在看他最喜欢的电视彩票节目,希望能一夜暴富。彩票球在旋转和碰撞后,摇出了以下号码:2, 5, 7, 11, 19, 23 和 31。

Vedran 叹了口气,因为他一个数字也没猜中。“看来我已经过了我的‘黄金(质数)’时期了……”他一边关掉旧电视,一边自言自语道。他的视力也越来越差,所以按错了遥控器上的按钮,切换到了 COCI 频道。

主持人 Malnar 先生平静地说道:“亲爱的观众朋友们,在屏幕左侧我会给出一个质数 $A$,在屏幕右侧我会给出一个质数 $B$。第一个打进电话并给出一个质数数组的人,如果该数组以 $A$ 开头、以 $B$ 结尾,且任意两个相邻元素之间的绝对差也是一个质数,那么他将获得免费去新加坡参加 IOI 2020 的旅行。”

年迈的 Vedran 正在回忆他作为竞赛程序员的辉煌岁月。不幸的是,他已经生疏了,无法解决这个问题。心地善良的你决定帮助 Vedran 赢得去新加坡的旅行。

注意:质数是大于 1 且只能被 1 和它自身整除的正整数。

输入格式

第一行包含两个质数 $A$ 和 $B$($2 \le A, B \le 10^{14}$,$A \ne B$),含义如题面所述。

输出格式

如果任务是不可能的,即不存在满足题面条件的数组,只需在单行中输出 -1

否则,在第一行输出数组中的元素个数,在第二行输出数组的元素,用空格隔开。数组的大小不能超过 $30$,且其元素不能超过 $10^{15}$。保证如果存在解,则至少存在一个满足这些限制的解。

如果有多组正确解,输出其中任意一组即可。

数据范围

  • 在占总分 14 分的测试点中,如果存在解,则至少存在一个满足以下条件的解:结果数组中的元素个数不超过 $3$,且所有元素均不超过 $1000$。
  • 在额外占 28 分的测试点中,满足 $2 \le A, B \le 1000$。

样例

输入样例 1

13 11

输出样例 1

2
13 11

输入样例 2

37 11

输出样例 2

-1

输入样例 3

2 17

输出样例 3

3
2 19 17

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.