[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 ...
随机推荐
- 如何解决Asp.Net MVC和WebAPI的Controller名称不能相同的问题
1.问题描述 假如有一个文章的业务(Article),我们在 Controllers文件夹中创建MVC Controller和Api Controller,各个Controller中都有相同的获取文章 ...
- mathjax
MathJax.Hub.Typeset() method. This will cause the preprocessors (if any were loaded) to run over the ...
- show processlist,sysbench压力测试工具
processlist.sh 记录数据库的状态 #!/bin/bash while true do mysql -uroot -pwangxiaohu -e 'show processlist\G'| ...
- Linux离线同步时间
Linux离线同步时间 思路:以其中一台时间为准 脚本 #!/bin/shcurrent=`date '+%H:%M:%S'` for i in bigdata1 bigdata2 bigdata3 ...
- UOJ279 【UTR #2】题目交流通道
本文版权归ljh2000和博客园共有,欢迎转载,但须保留此声明,并给出原文链接,谢谢合作. 本文作者:ljh2000 作者博客:http://www.cnblogs.com/ljh2000-jump ...
- Linux- 自动备份MySQL数据库脚本
数据安全很重要,所以日常中需要对数据库进行备份.
- spring学习(2)
理解反向控制(IOC) 依赖注入(di):比IOC更好地名字.获得依赖对象的方式反转了. IOC应用 IOC或者di,还可以达到解耦的目的. spring开发提倡接口编程,配合di技术,可以更好地达到 ...
- angularjs $http提交数据探索
前两天在搞自己的项目,前端js框架用的是angularjs框架:网站整的差不多的时候出事了:那就是当我用$http.post()方法向服务器提交一些数据的时候:后台总是接收不到数据: 于是采用了其他方 ...
- js 禁止用户使用Ctrl+鼠标滚轮缩放网页
为什么会有人会使用ctrl+鼠标滚轮缩放网页?坚决禁止! <html> <head> <title>测试</title> <script lang ...
- SSAS——基础
一.Analysis Services Analysis Services是用于决策支持和BI解决方案的数据引擎.它提供报表和客户端中使用的分析数据. 它可在多用途数据模型中创建高性能查询结构,业务逻 ...