zoukankan      html  css  js  c++  java
  • codefoces 1400B RPG Protagonist

    https://codeforces.com/contest/1400/problem/B

    有一点很重要,s能用完就一定会用完,枚举我用几个s就好

    #include<iostream>
    #include<cstring>
    #include<queue>
    #include<algorithm>
    using namespace std;
    typedef long long ll;
    ll t,p,f,cnta,cntb,s,w;
    
    int main(){
    	cin>>t;
    	while(t--){
    		cin>>p>>f;
    		cin>>cnta>>cntb;
    		cin>>s>>w;
    		ll ans = 0; 
    		if(s > w){
    			swap(s,w);
    			swap(cnta,cntb);
    		}
    		for(ll i=0;i<=cnta && i*s <= p;i++){//我用i个s,他用cnta - i 个s 
    			ll k = cntb;
    			ll b = min(k,(p-i*s)/w);//我用几个w
    			k -= b;
    			
    			if( (cnta - i)*s > f ){//随从全用s
    				ans = max(ans,i + f/s + b);
    			}
    			else{
    				ll c = min(k,(f - (cnta - i)*s) / w);
    				
    				ans = max(ans,c + cnta + b);
    			}
    		}
    		cout<<ans<<endl;
    	}
    	return 0;
    }
    

      

    寻找真正的热爱
  • 相关阅读:
    python连接redis
    python3进行md5加密
    python操作mysql数据库
    python3操作excle
    memcache与redis的存储类型
    模块
    函数
    json与字典相互转换
    常用的Random函数
    字符串常用方法
  • 原文地址:https://www.cnblogs.com/lesning/p/13607737.html
Copyright © 2011-2022 走看看