[413D][搜索]D - Field expansion
http://codeforces.com/contest/799/problem/D
解题关键:因为3^11>100000,所以若只把2单独拿出,最多只需要暴力2^11次,故只需要dfs一下即可。
#include<bits/stdc++.h>
#define INF 0x3f3f3f3f
using namespace std;
typedef long long ll;
ll a,b,h,w,n,d[],ans;
void dfs(ll aa,ll bb,ll x){
if(aa>=a&&bb>=b){ ans=min(ans,x);return;}
if(x==n+) return;
if(d[x]==){
while(aa<a){aa<<=,x++;}
while(bb<b){bb<<=,x++;}
ans=min(x,ans);
return;
} if(aa<a) dfs(aa*d[x],bb,x+);
if(bb<b) dfs(aa,bb*d[x],x+);
}
int main(){
cin>>a>>b>>h>>w>>n;
for(ll i=;i<n;i++) cin>>d[i];
sort(d,d+n,greater<ll>());
ans=n+;
dfs(h,w,);
dfs(w,h,);
ans=(ans==n+?-:ans);
cout<<ans<<endl;
return ;
}
[413D][搜索]D - Field expansion的更多相关文章
- Codeforces 799D Field expansion - 搜索 - 贪心
In one of the games Arkady is fond of the game process happens on a rectangular field. In the game p ...
- Playrix Codescapes Cup (Codeforces Round #413, rated, Div. 1 + Div. 2) D. Field expansion
D. Field expansion time limit per test 1 second memory limit per test 256 megabytes input standard i ...
- Codeforces 799D Field expansion(随机算法)
Field expansion [题目链接]Field expansion [题目类型]随机化算法 &题解: 参考自:http://www.cnblogs.com/Dragon-Light/p ...
- 【动态规划】【滚动数组】【搜索】Playrix Codescapes Cup (Codeforces Round #413, rated, Div. 1 + Div. 2) D. Field expansion
显然将扩张按从大到小排序之后,只有不超过前34个有效. d[i][j]表示使用前i个扩张,当length为j时,所能得到的最大的width是多少. 然后用二重循环更新即可, d[i][j*A[i]]= ...
- Codeforces 799 D. Field expansion
题目链接:http://codeforces.com/contest/799/problem/D 因为${a_i>=2}$那么一个数字至多操作${log_{2}^{max(a,b)/min(h, ...
- 【贪心+DFS】D. Field expansion
http://codeforces.com/contest/799/problem/D [题意] 给定长方形的两条边h和w,你可以从给出的n个数字中随意选出一个x,把h或者w乘上x(每个x最多用一次) ...
- 【codeforces 799D】Field expansion
[题目链接]:http://codeforces.com/contest/799/problem/D [题意] 给你长方形的两条边h,w; 你每次可以从n个数字中选出一个数字x; 然后把h或w乘上x; ...
- codeforces 799 D. Field expansion(dfs+思维剪枝)
题目链接:http://codeforces.com/contest/799/problem/D 题意:给出h*w的矩阵,要求经过操作使得h*w的矩阵能够放下a*b的矩阵,操作为:将长或者宽*z[i] ...
- Lucene.net 从创建索引到搜索的代码范例
关于Lucene.Net的介绍网上已经很多了在这里就不多介绍Lucene.Net主要分为建立索引,维护索引和搜索索引Field.Store的作用是通过全文检查就能返回对应的内容,而不必再通过id去DB ...
随机推荐
- gsub! 和 gsub
ruby中带“!"和不带"!"的方法的最大的区别就是带”!"的会改变调用对象本身了.比方说str.gsub(/a/, 'b'),不会改变str本身,只会返回一个 ...
- LintCode:链表操作(合并与反转)
描述: (1)翻转一个链表 样例 给出一个链表1->2->3->null,这个翻转后的链表为3->2->1->null ********************** ...
- 2018svn1
Svn(Subversion) VisualSVN-Server是SVN的服务端.TortoiseSVN是客户端.D:\SVNRepositories是安装VisualSVN-Server时候选择的仓 ...
- python中reduce()函数
reduce()函数也是Python内置的一个高阶函数.reduce()函数接收的参数和 map()类似,一个函数 f,一个list,但行为和 map()不同,reduce()传入的函数 f 必须接收 ...
- 20145210姚思羽《网络对抗》——shellcode注入& Return-to-libc攻击深入
20145210姚思羽<网络对抗>shellcode注入&Return-to-libc攻击深入 shellcode基础知识 Shellcode是一段代码,作为数据发送给受攻击服务器 ...
- Ubuntu下,grep的用法
grep(Global search Regular Expression and Print out the line)是一种强大的文本搜索工具,它能使用正则表达式搜索文本,并把匹配的行打印出来.U ...
- HDU1232 畅通工程,并查集
这里要补充一些知识点,并查集三操作 1.找到父节点递归写法int Findf(int x){ if(father[x]!=x) father[x]=Findf(father[x]); return f ...
- MySQL部署时Table 'mysql.plugin' doesn't exist的解决
今天部署了免安装版的MySQL,出现了Table 'mysql.plugin' doesn't exist的问题,苦恼了好久,终于在网上找到了解决方案,现整理一下给大家分享: 系统环境:Win10 6 ...
- TortoiseGit做push时提示Disconnected: No supported authentication methods available (server sent: publickey)错误
通过Git从远程服务器上获得到自己的项目,但是通过TortoiseGit做push时提示Disconnected: No supported authentication methods availa ...
- php之定义大字符串数据时使用定界符来标识
在定义大字符串数据时,通常使用定界符来标识,这种方式能保留文本中的格式,如文本中的换行.定界符使用格式如下. <<<identifier 格式化文本 identifier 其中,符号 ...