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 ...
随机推荐
- Linux分区的几种方案
通用方法/boot 引导分区 200M swap 交换分区 内存的1.5倍(内存小于8G) 大于8G 给8G/ 根分区 剩下多少给多少 数据非常重要/bootswap/ 50-200G/data 剩下 ...
- Python requests模块解析XML
检查QQ是否在线(api感觉不准) import requests from xml.etree import ElementTree qq_str = input('please input the ...
- git 冲突解决的方法
版权声明:本文为博主原创文章,未经博主同意不得转载. 新博客地址:www.atomicdevelop.com https://blog.csdn.net/believer123/article/det ...
- 1.java的基础和数据类型
一.学习要求1.听课一定要全神贯注2.课堂笔记,一定要自己总结,而且要有很严谨的逻辑关系.提纲很重要3.作业不折不扣的完成,并且多完成4.阶段项目一定要独立完成5.每天早上由一位同学来进行早分享,内容 ...
- day26 Python 改变对象的字符串显示
__str__,__repr__,__format__ format_dict={ 'nat':'{obj.name}-{obj.addr}-{obj.type}',#学校名-学校地址-学校类型 't ...
- AI tensorflow MNIST
MNIST 数据 train-images-idx3-ubyte.gz:训练集图片 train-labels-idx1-ubyte.gz:训练集图片类别 t10k-images-idx3-ubyte. ...
- Gulp压缩前端CS,JS,图片文件
Gulp 基于Node.js的前端构建工具,Gulp有许多插件(这里是插件),使用Gulp可以实现前端代码的编译(sass.less).压缩.图片的压缩等,当然主要是前端工程化,不过我目前只是需要压缩 ...
- SpringBoot集成Freemarker与Thymeleaf
一:概括 pom.xml添加依赖 配置application.yml HTML页面使用表达式 二:Freemarker模板引擎 1.添加依赖 <!-- ftl模板引擎 --> <de ...
- 五、xadmin自定义插件2
以导入插件为例说明: 1.在xadmin-->plugins下面新建excel.py文件 2.新建ListExcelImportPlugin类,继承BaseAdminPlugin from xa ...
- OSGI嵌入jetty应用服务器
1.搭建osgi基础环境,参考:https://www.cnblogs.com/dyh004/p/10642383.html 2.引入jetty相关的依赖包 修改jetty启动端口 3.com.ksz ...