A12295 | Professional layer
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Cardbluff is popular sport game in Telegram. Each Cardbluff player has ever dreamed about entrance in the professional layer. There are $n$ judges now in the layer and you are trying to pass the entrance exam. You have a number $k$ — your skill in Cardbluff.
Each judge has a number $a_i$ — an indicator of uncertainty about your entrance to the professional layer and a number $e_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 $i$ -th judge by any natural divisor of $a_i$ which is at most $k$ . If GCD of all indicators is equal to $1$ , 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 $x$ judges with total experience $y$ you will spend $x \cdot y$ seconds.
Print minimal time to enter to the professional layer or $-1$ if it's impossible.
Each judge has a number $a_i$ — an indicator of uncertainty about your entrance to the professional layer and a number $e_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 $i$ -th judge by any natural divisor of $a_i$ which is at most $k$ . If GCD of all indicators is equal to $1$ , 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 $x$ judges with total experience $y$ you will spend $x \cdot y$ seconds.
Print minimal time to enter to the professional layer or $-1$ if it's impossible.
输入格式
There are two numbers in the first line $n$ and $k$ ( $1 \leq n \leq 10^6$ , $1 \leq k \leq 10^{12}$ ) — the number of judges and your skill in Cardbluff.
The second line contains $n$ integers, where $i$ -th number $a_i$ ( $1 \leq a_i \leq 10^{12}$ ) — the uncertainty of $i$ -th judge
The third line contains $n$ integers in the same format ( $1 \leq e_i \leq 10^9$ ), $e_i$ — the experience of $i$ -th judge.
The second line contains $n$ integers, where $i$ -th number $a_i$ ( $1 \leq a_i \leq 10^{12}$ ) — the uncertainty of $i$ -th judge
The third line contains $n$ integers in the same format ( $1 \leq e_i \leq 10^9$ ), $e_i$ — the experience of $i$ -th judge.
输出格式
Print the single integer — minimal number of seconds to pass exam, or $-1$ if it's impossible
输入输出样例
输入 #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
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted