CF1103D.Professional layer

NOI/NOI+/CTSC

通过率:0%

时间限制:3.00s

内存限制:512MB

AC君温馨提醒

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

题目描述

Cardbluff is popular sport game in Telegram. Each Cardbluff player has ever dreamed about entrance in the professional layer. There are nn judges now in the layer and you are trying to pass the entrance exam. You have a number kk — your skill in Cardbluff.

Each judge has a number aia_i — an indicator of uncertainty about your entrance to the professional layer and a number eie_i — an experience playing Cardbluff. To pass the exam you need to convince all judges by playing with them. You can play only one game with each judge. As a result of a particular game, you can divide the uncertainty of ii-th judge by any natural divisor of aia_i which is at most kk. If GCD of all indicators is equal to 11, you will enter to the professional layer and become a judge.

Also, you want to minimize the total amount of spent time. So, if you play with xx judges with total experience yy you will spend x⋅yx \cdot y seconds.

Print minimal time to enter to the professional layer or −1-1 if it's impossible.

Cardbluff 是 Telegram 上一项流行的体育游戏。每位 Cardbluff 玩家都曾梦想进入职业圈。目前职业圈内共有 nn 位评委,而你正试图通过入圈考试。你拥有一个数值 kk —— 表示你在 Cardbluff 方面的技能水平。

每位评委 ii 拥有两个数值:aia_i(表示其对你能否进入职业圈所持的不确定性指标)和 eie_i(表示其玩 Cardbluff 的经验)。要通过考试,你必须通过与每位评委对战来说服他们。你只能与每位评委进行一局游戏。在与第 ii 位评委的对局中,你可以将该评委的不确定性 aia_i 除以 aia_i 的任意一个不超过 kk 的正整数因子(即:若 d∣aid \mid a_i 且 1≤d≤k1 \le d \le k,则可将 aia_i 替换为 ai/da_i / d)。当所有评委的不确定性指标的最大公约数(GCD)等于 1 时,你便成功进入职业圈,并成为一名评委。

此外,你还希望最小化总耗时。具体而言:若你与 xx 位评委对战,这些评委的经验值之和为 yy,则你总共将花费 x⋅yx \cdot y 秒。

请输出进入职业圈所需的最短时间;若不可能实现,则输出 −1-1。

输入格式

There are two numbers in the first line nn and kk (1≤n≤1061 \leq n \leq 10^6, 1≤k≤10121 \leq k \leq 10^{12}) — the number of judges and your skill in Cardbluff.

The second line contains nn integers, where ii-th number aia_i (1≤ai≤10121 \leq a_i \leq 10^{12}) — the uncertainty of ii-th judge

The third line contains nn integers in the same format (1≤ei≤1091 \leq e_i \leq 10^9), eie_i — the experience of ii-th judge.

第一行包含两个整数 nn 和 kk(1≤n≤1061 \leq n \leq 10^6,1≤k≤10121 \leq k \leq 10^{12})—— 分别表示评委人数和你在“卡牌虚张声势”(Cardbluff)游戏中的技能值。

第二行包含 nn 个整数,其中第 ii 个数 aia_i(1≤ai≤10121 \leq a_i \leq 10^{12})表示第 ii 位评委的不确定性。

第三行同样包含 nn 个整数(1≤ei≤1091 \leq e_i \leq 10^9),其中 eie_i 表示第 ii 位评委的经验值。

输出格式

Print the single integer — minimal number of seconds to pass exam, or −1-1 if it's impossible

输出一个整数——通过考试所需的最少秒数;若无法通过考试,则输出 −1-1

输入输出样例

  • 输入#1

    3 6
    30 30 30
    100 4 5

    输出#1

    18
  • 输入#2

    1 1000000
    1
    100

    输出#2

    0
  • 输入#3

    3 5
    7 7 7
    1 1 1

    输出#3

    -1

输入解题思路,AI测评打分。不知道怎么写?

首页