A9759 | Friends and Presents
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
You have two friends. You want to present each of them several positive integers. You want to present $cnt_{1}$ numbers to the first friend and $cnt_{2}$ numbers to the second friend. Moreover, you want all presented numbers to be distinct, that also means that no number should be presented to both friends.
In addition, the first friend does not like the numbers that are divisible without remainder by prime number $x$ . The second one does not like the numbers that are divisible without remainder by prime number $y$ . Of course, you're not going to present your friends numbers they don't like.
Your task is to find such minimum number $v$ , that you can form presents using numbers from a set $1,2,...,v$ . Of course you may choose not to present some numbers at all.
A positive integer number greater than 1 is called prime if it has no positive divisors other than 1 and itself.
In addition, the first friend does not like the numbers that are divisible without remainder by prime number $x$ . The second one does not like the numbers that are divisible without remainder by prime number $y$ . Of course, you're not going to present your friends numbers they don't like.
Your task is to find such minimum number $v$ , that you can form presents using numbers from a set $1,2,...,v$ . Of course you may choose not to present some numbers at all.
A positive integer number greater than 1 is called prime if it has no positive divisors other than 1 and itself.
输入格式
You have two friends. You want to present each of them several positive integers. You want to present $cnt_{1}$ numbers to the first friend and $cnt_{2}$ numbers to the second friend. Moreover, you want all presented numbers to be distinct, that also means that no number should be presented to both friends.
In addition, the first friend does not like the numbers that are divisible without remainder by prime number $x$ . The second one does not like the numbers that are divisible without remainder by prime number $y$ . Of course, you're not going to present your friends numbers they don't like.
Your task is to find such minimum number $v$ , that you can form presents using numbers from a set $1,2,...,v$ . Of course you may choose not to present some numbers at all.
A positive integer number greater than 1 is called prime if it has no positive divisors other than 1 and itself.
In addition, the first friend does not like the numbers that are divisible without remainder by prime number $x$ . The second one does not like the numbers that are divisible without remainder by prime number $y$ . Of course, you're not going to present your friends numbers they don't like.
Your task is to find such minimum number $v$ , that you can form presents using numbers from a set $1,2,...,v$ . Of course you may choose not to present some numbers at all.
A positive integer number greater than 1 is called prime if it has no positive divisors other than 1 and itself.
输出格式
Print a single integer — the answer to the problem.
输入输出样例
输入 #1
3 1 2 3
输出 #1
5
输入 #2
1 3 2 3
输出 #2
4
In the first sample you give the set of numbers ${1,3,5}$ to the first friend and the set of numbers ${2}$ to the second friend. Note that if you give set ${1,3,5}$ to the first friend, then we cannot give any of the numbers $1$ , $3$ , $5$ to the second friend.
In the second sample you give the set of numbers ${3}$ to the first friend, and the set of numbers ${1,2,4}$ to the second friend. Thus, the answer to the problem is $4$ .
In the second sample you give the set of numbers ${3}$ to the first friend, and the set of numbers ${1,2,4}$ to the second friend. Thus, the answer to the problem is $4$ .
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted