A10901 | Field expansion
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
In one of the games Arkady is fond of the game process happens on a rectangular field. In the game process Arkady can buy extensions for his field, each extension enlarges one of the field sizes in a particular number of times. Formally, there are $n$ extensions, the $i$ -th of them multiplies the width or the length (by Arkady's choice) by $a_{i}$ . Each extension can't be used more than once, the extensions can be used in any order.
Now Arkady's field has size $h×w$ . He wants to enlarge it so that it is possible to place a rectangle of size $a×b$ on it (along the width or along the length, with sides parallel to the field sides). Find the minimum number of extensions needed to reach Arkady's goal.
Now Arkady's field has size $h×w$ . He wants to enlarge it so that it is possible to place a rectangle of size $a×b$ on it (along the width or along the length, with sides parallel to the field sides). Find the minimum number of extensions needed to reach Arkady's goal.
输入格式
The first line contains five integers $a$ , $b$ , $h$ , $w$ and $n$ ( $1<=a,b,h,w,n<=100000$ ) — the sizes of the rectangle needed to be placed, the initial sizes of the field and the number of available extensions.
The second line contains $n$ integers $a_{1},a_{2},...,a_{n}$ ( $2<=a_{i}<=100000$ ), where $a_{i}$ equals the integer a side multiplies by when the $i$ -th extension is applied.
The second line contains $n$ integers $a_{1},a_{2},...,a_{n}$ ( $2<=a_{i}<=100000$ ), where $a_{i}$ equals the integer a side multiplies by when the $i$ -th extension is applied.
输出格式
Print the minimum number of extensions needed to reach Arkady's goal. If it is not possible to place the rectangle on the field with all extensions, print -1. If the rectangle can be placed on the initial field, print 0.
输入输出样例
输入 #1
3 3 2 4 4 2 5 4 10
输出 #1
1
输入 #2
3 3 3 3 5 2 3 5 4 2
输出 #2
0
输入 #3
5 5 1 2 3 2 2 3
输出 #3
-1
输入 #4
3 4 1 1 3 2 3 2
输出 #4
3
In the first example it is enough to use any of the extensions available. For example, we can enlarge $h$ in $5$ times using the second extension. Then $h$ becomes equal $10$ and it is now possible to place the rectangle on the field.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted