Codeforces 1154C Gourmet Cat
题目链接:http://codeforces.com/problemset/problem/1154/C
题目大意:
主人有一只猫。
周一&周四&周日:吃鱼
周二&周六:吃兔子
周三&周五:吃鸡
他们现在要外出旅游。他们带了一个包,包里有:
a份鱼肉
b份兔肉
c份鸡肉
问,猫的主人在最优解的情况下(即他可以自由的选择周几出去旅游),最多可以多少天不额外在外购买猫粮?(即,这个包最多能够猫吃多少天)
【猫一天就吃一份】
分析:
首先把能吃完整7天的食量减掉,接下来的食物配比就只能吃0~6天了,可以把满足能吃i(0 < i < 7)天的所有实物配比情况全部列出来,再枚举,能大大减少代码量。
代码如下:
#include <bits/stdc++.h>
using namespace std; #define rep(i,n) for (int i = 0; i < (n); ++i)
#define For(i,s,t) for (int i = (s); i <= (t); ++i)
#define rFor(i,t,s) for (int i = (t); i >= (s); --i)
#define foreach(i,c) for (__typeof(c.begin()) i = c.begin(); i != c.end(); ++i)
#define rforeach(i,c) for (__typeof(c.rbegin()) i = c.rbegin(); i != c.rend(); ++i) #define pr(x) cout << #x << " = " << x << " "
#define prln(x) cout << #x << " = " << x << endl #define LOWBIT(x) ((x)&(-x)) #define ALL(x) x.begin(),x.end()
#define INS(x) inserter(x,x.begin()) #define ms0(a) memset(a,0,sizeof(a))
#define msI(a) memset(a,inf,sizeof(a))
#define msM(a) memset(a,-1,sizeof(a)) #define pii pair<int,int>
#define piii pair<pair<int,int>,int>
#define mp make_pair
#define pb push_back
#define fi first
#define se second inline int gc(){
static const int BUF = 1e7;
static char buf[BUF], *bg = buf + BUF, *ed = bg; if(bg == ed) fread(bg = buf, , BUF, stdin);
return *bg++;
} inline int ri(){
int x = , f = , c = gc();
for(; c<||c>; f = c=='-'?-:f, c=gc());
for(; c>&&c<; x = x* + c - , c=gc());
return x*f;
} typedef long long LL;
typedef unsigned long long uLL;
const double EPS = 1e-;
const int inf = 1e9 + ;
const LL mod = 1e9 + ;
const int maxN = 1e5 + ;
const LL ONE = ; struct Food{
int x, y, z;
}; int n, a, b, c, ans;
vector< Food > foods[] = {
{Food(, , ), Food(, , ), Food(, , )},
{Food(, , ), Food(, , ), Food(, , ), Food(, , )},
{Food(, , ), Food(, , ), Food(, , )},
{Food(, , ), Food(, , ), Food(, , )},
{Food(, , ), Food(, , ), Food(, , )},
{Food(, , ), Food(, , ), Food(, , )}
}; int main(){
cin >> a >> b >> c;
int t = min(min(a / , b / ), c / ); ans += * t;
a -= * t;
b -= * t;
c -= * t; rFor(i, , ) {
foreach(j, foods[i]) {
if(a >= j->x && b >= j->y && c >= j->z) {
a -= j->x; b -= j->y; c -= j->z;
ans += i + ;
i = ;
break;
} }
} cout << ans << endl;
return ;
}
Codeforces 1154C Gourmet Cat的更多相关文章
- Codeforces Round #552 (Div. 3) C. Gourmet Cat (数学,模拟)
题意:你要带着你的喵咪一起去旅行,你的喵在星期\(1,4,7\)吃喵粮\(x\),在星期\(2,6\)吃喵粮\(y\),在星期\(3,5\)吃喵粮\(z\),你只有\(a\)个\(x\),\(b\)个 ...
- Codeforces 589F Gourmet and Banquet
A gourmet came into the banquet hall, where the cooks suggested n dishes for guests. The gourmet kno ...
- codeforces 589F. Gourmet and Banquet 二分+网络流
题目链接 给你n种菜, 每一种可以开始吃的时间不一样, 结束的时间也不一样. 求每种菜吃的时间都相同的最大的时间.时间的范围是0-10000. 看到这个题明显可以想到网络流, 但是时间的范围明显不允许 ...
- Codeforces 1154 - A/B/C/D/E/F/G - (Undone)
链接:https://codeforces.com/contest/1154 A - Restoring Three Numbers - [水] #include<bits/stdc++.h&g ...
- Codeforces Round #552 (Div. 3) 题解
Codeforces Round #552 (Div. 3) 题目链接 A. Restoring Three Numbers 给出 \(a+b\),\(b+c\),\(a+c\) 以及 \(a+b+c ...
- CodeForces Round #552 Div.3
A. Restoring Three Numbers 代码: #include <bits/stdc++.h> using namespace std; ]; int a, b, c; i ...
- CF #552 div3
A - Restoring Three Numbers CodeForces - 1154A Polycarp has guessed three positive integers aa, bb a ...
- Codeforces #541 (Div2) - D. Gourmet choice(拓扑排序+并查集)
Problem Codeforces #541 (Div2) - D. Gourmet choice Time Limit: 2000 mSec Problem Description Input ...
- Codeforces Round #554 (Div. 2) 1152B. Neko Performs Cat Furrier Transform
学了这么久,来打一次CF看看自己学的怎么样吧 too young too simple 1152B. Neko Performs Cat Furrier Transform 题目链接:"ht ...
随机推荐
- 2018年6月,最新php工程师面试总结
面试经常被问到的问题总结 1.字符串函数 2.数组函数 3.cookie和session的区别 4.状态码以及其功能
- [tool] Visual Studio Code python配置
语言设置 安装中文插件即可成为中文 选择一个Python解释器 Python是一种解释型语言,为了运行Python代码并获取Python IntelliSense,您必须告诉VS Code使用哪个解释 ...
- ORA-00600: internal error code, arguments: [2662]
转自 http://www.eygle.com/archives/2005/12/oracle_diagnostics_howto_deal_2662_error.html 在ORA-00600 22 ...
- OmniPlan 3 Pro密钥
密钥用户名都是youliyuan.OmniPlan 3:HOMJ-QOJH-OIBN-TNIH-HWUN-TEEH-WUNNKWO-HVKB-JAZE-UIHH-XAVY-BEEX-AVYBCRW-M ...
- hdu4966 GGS-DDU
hdu4966 GGS-DDU 有 \(n\) 个课程,每种课程有 \(a_i\) 级,一开始你每种课程都为 \(0\) 级,有 \(m\) 个升级方案:\((x,\ l1,\ y,\ l2,\ c) ...
- Can 't connect to local MySQL server through socket '/tmp/mysql.sock '(2) "
安装了mysql, 使用命令mysql -u root -p 弹出Can 't connect to local MySQL server through socket '/tmp/mysql.soc ...
- Feature Extractor[content]
0. AlexNet 1. VGG VGG网络相对来说,结构简单,通俗易懂,作者通过分析2013年imagenet的比赛的最好模型,并发现感受野还是小的好,然后再加上<network in ne ...
- Python 学习 第十篇:正则表达式 - re
规则表达式(Regular Expression, RE),又称作正则表达式,通常用于检索.替换符合指定规则的文本,正则表达式定义的规则,称作模式(Pattern),即正则表达式的作用是从文本中查找到 ...
- mybatis 多个接口参数的注解使用方式(@Param)
目录 1 简介 1.1 单参数 1.2 多参数 2 多个接口参数的两种使用方式 2.1 Map 方法(不推荐) 2.1.1 创建接口方法 2.1.2 配置对应的SQL 2.1.3 调用 2.2 @Pa ...
- Python股票分析系列——自动获取标普500股票列表.p5
该系列视频已经搬运至bilibili: 点击查看 欢迎来到Python for Finance教程系列的第5部分.在本教程和接下来的几节中,我们将着手研究如何为更多公司提供大量的定价信息,以及如何一次 ...