枚举 ---- B. RPG Protagonist[Educational Codeforces Round 94 (Rated for Div. 2)]数学枚举
B. RPG Protagonist
题目大意:就是你有两个人,每个人都有一个最大的体力值p和f,这两个人要去搬运剑和盾牌,剑的数量是cnts,盾的数量是cntw,每个剑的重量是是s,每个盾的重量是w,问你最多可以搬运多少武器
解题思路:一眼就是一个贪心题但是如何贪心确是一个问题?
很显然剑和盾哪个轻就拿哪个为了直观一点,我们可以设出这些自变量了
****
#include <iostream>
#include <cstdio>
#include <stack>
#include <sstream>
#include <limits.h>
#include <vector>
#include <map>
#include <cstring>
#include <deque>
#include <cmath>
#include <iomanip>
#include <unordered_map>
#include <queue>
#include <algorithm>
#include <set>
#define mid ((l + r) >> 1)
#define Lson rt << 1, l , mid
#define Rson rt << 1|1, mid + 1, r
#define ms(a,al) memset(a,al,sizeof(a))
#define log2(a) log(a)/log(2)
#define _for(i,a,b) for( int i = (a); i < (b); ++i)
#define _rep(i,a,b) for( int i = (a); i <= (b); ++i)
#define for_(i,a,b) for( int i = (a); i >= (b); -- i)
#define rep_(i,a,b) for( int i = (a); i > (b); -- i)
#define lowbit(x) ((-x) & x)
#define IOS std::ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define INF 0x3f3f3f3f
#define LLF 0x3f3f3f3f3f3f3f3f
#define hash Hash
#define next Next
#define pb push_back
#define f first
#define s second
using namespace std;
const int N = 1e7 + 10, MOD = 1e9 + 7;
const int maxn = 2e5;
const long double eps = 1e-5;
const int EPS = 500 * 500;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef pair<double,double> PDD;
template<typename T> void read(T &x)
{x = 0;char ch = getchar();ll f = 1;while(!isdigit(ch)){if(ch == '-')f*=-1;ch=getchar();}while(isdigit(ch)){x = x*10+ch-48;ch=getchar();}x*=f;
}
template<typename T, typename... Args> void read(T &first, Args& ... args)
{read(first);read(args...);
}
int T, n;
string s;
int main()
{read(T);while(T --){int p, f;int cs,cw;int s, w;read(p,f);read(cs,cw);read(s,w);if (s>w){swap(s,w);swap(cs,cw);}int ans = 0;for (int s1=0;s1*s<=p && s1<=cs;s1++){int w1=min((p-s1*s)/w,cw);int s2=min(cs-s1,f/s);int w2=min((f-s2*s)/w,cw-w1);ans=max(ans,s1+s2+w1+w2);}cout << ans << endl;}return 0;
}
枚举 ---- B. RPG Protagonist[Educational Codeforces Round 94 (Rated for Div. 2)]数学枚举相关推荐
- 枚举 ---- D. Zigzags[ Educational Codeforces Round 94 (Rated for Div. 2)]思维枚举优化4重循环
D. Zigzags 题目大意:就是给你i<j<k<l并且aj=al&&ai=aki<j<k<l并且a_j=a_l \&\& a_i ...
- Educational Codeforces Round 94 (Rated for Div. 2)
这次做了ABCD,今天下午就要上学去了溜了溜了,早上起来补的题解. A - String Similarity 分析可知可构造w[i]=s[2*i]即可满足题意 #define IO ios::syn ...
- Educational Codeforces Round 94 (Rated for Div. 2)题解ABCD
A. String Similarity 题目传送门 String Similarity 题目大意 给你一个n和一个长度为2∗n−12*n-12∗n−1的01字符串,对于给定字符串,你需要构造一个长度 ...
- Educational Codeforces Round 94 (Rated for Div. 2) D(思维)
题目: You are given an array a1,a2-an. Calculate the number of tuples (i,j,k,l) such that: 1≤i<j< ...
- Educational Codeforces Round 90 (Rated for Div. 2)(A, B, C, D, E)
Educational Codeforces Round 90 (Rated for Div. 2) Donut Shops 思路 分三种情况: a==c/ba == c / ba==c/b这个时候两 ...
- Educational Codeforces Round 114 (Rated for Div. 2) D. The Strongest Build 暴力 + bfs
传送门 文章目录 题意: 思路: 题意: 你有nnn个装备槽,每个槽里面有cic_ici个力量加成,对于每个槽只能选一个力量加成,现在给你mmm个力量组合[b1,b2,...,bn][b_1,b_2 ...
- Educational Codeforces Round 111 (Rated for Div. 2) E. Stringforces 二分 + 状压dp
传送门 文章目录 题意: 思路: 题意: 给你一个串,只包含前kkk个字母和???,定义fif_ifi表示第iii个字母在串中出现的最长连续长度,你现在需要将???替换为前kkk个字母,使得mini ...
- Educational Codeforces Round 73 (Rated for Div. 2) F. Choose a Square 线段树 + 二维转一维
传送门 文章目录 题意: 思路: 题意: 给你nnn个点(xi,yi)(x_i,y_i)(xi,yi),每个点有个价值cic_ici,现在你可以框一个正方形,要求左下角和右上角的坐标(x,y)( ...
- Educational Codeforces Round 73 (Rated for Div. 2) E. Game With String 思维博弈 好题(2500)
传送门 文章目录 题意: 思路: 题意: 思路: 我们将每一段...拿出来看成若干段,将其分成以下四种情况: (1)len<b(1)len<b(1)len<b (2)b≤len< ...
最新文章
- mysql 协议说明_MySQL认证协议_MySQL
- plotly可视化绘制多子图(subplots)共享坐标轴
- java计数器策略模式_策略模式与外观模式 | 学步园
- Linux学习笔记033_10
- 详解linux下安装python3环境
- Vue使用Element-ui按需引入大坑
- 【零基础学Java】—笔记本USB接口案例(二十八)
- USB2.0协议学习笔记---USB工作过程(类的方法)
- 性能测试--jmeter中的察看结果树【7】
- 电商实训三:网店经营
- centos安装open-jdk8
- 我的项目经验v3.0
- 向量叉乘的线性性质 几何解释
- 什么是Trunk端口模式?此模式有何作用?
- Heuristic function
- Java大作业——购物车
- 【读书笔记】《解忧程序员》读后感
- 关闭win7的程序兼容性助手
- OSChina 周一乱弹 ——强行把她拖到家里洗了个澡
- HDU1234 开门人和关门人