题目链接: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的更多相关文章

  1. Codeforces Round #552 (Div. 3) C. Gourmet Cat (数学,模拟)

    题意:你要带着你的喵咪一起去旅行,你的喵在星期\(1,4,7\)吃喵粮\(x\),在星期\(2,6\)吃喵粮\(y\),在星期\(3,5\)吃喵粮\(z\),你只有\(a\)个\(x\),\(b\)个 ...

  2. Codeforces 589F Gourmet and Banquet

    A gourmet came into the banquet hall, where the cooks suggested n dishes for guests. The gourmet kno ...

  3. codeforces 589F. Gourmet and Banquet 二分+网络流

    题目链接 给你n种菜, 每一种可以开始吃的时间不一样, 结束的时间也不一样. 求每种菜吃的时间都相同的最大的时间.时间的范围是0-10000. 看到这个题明显可以想到网络流, 但是时间的范围明显不允许 ...

  4. Codeforces 1154 - A/B/C/D/E/F/G - (Undone)

    链接:https://codeforces.com/contest/1154 A - Restoring Three Numbers - [水] #include<bits/stdc++.h&g ...

  5. Codeforces Round #552 (Div. 3) 题解

    Codeforces Round #552 (Div. 3) 题目链接 A. Restoring Three Numbers 给出 \(a+b\),\(b+c\),\(a+c\) 以及 \(a+b+c ...

  6. CodeForces Round #552 Div.3

    A. Restoring Three Numbers 代码: #include <bits/stdc++.h> using namespace std; ]; int a, b, c; i ...

  7. CF #552 div3

    A - Restoring Three Numbers CodeForces - 1154A Polycarp has guessed three positive integers aa, bb a ...

  8. Codeforces #541 (Div2) - D. Gourmet choice(拓扑排序+并查集)

    Problem   Codeforces #541 (Div2) - D. Gourmet choice Time Limit: 2000 mSec Problem Description Input ...

  9. Codeforces Round #554 (Div. 2) 1152B. Neko Performs Cat Furrier Transform

    学了这么久,来打一次CF看看自己学的怎么样吧 too young too simple 1152B. Neko Performs Cat Furrier Transform 题目链接:"ht ...

随机推荐

  1. Java锁的种类以及辨析(二):自旋锁的其他种类

    作者:山鸡 锁作为并发共享数据,保证一致性的工具,在JAVA平台有多种实现(如 synchronized 和 ReentrantLock等等 ) .这些已经写好提供的锁为我们开发提供了便利,但是锁的具 ...

  2. 设计模式C++实现——装饰者模式

    版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/walkerkalr/article/details/28633123 模式定义:         装 ...

  3. 启动线程用start方法

    启动线程用start方法而不是用run方法 public static void main(String[] args) { Thread t=new Thread("Thread-TEST ...

  4. 在Ubuntu上安装Jenkins

    先决条件 安装Java SDK sudo apt-get install openjdk-8-jdk # sudo apt-get install openjdk-7-jdk 早些系统可以安装 第1步 ...

  5. ddt框架优化(生成html报告注释内容传变量)

    https://blog.csdn.net/weixin_33923148/article/details/86017742 按要求修改后发现  注释只传值第一个变量 这是因为 ddt数据驱动生成ht ...

  6. 最长回文(manacher模板)

    #include<iostream> #include<algorithm> #include<cstring> #include<cstdio> us ...

  7. 第1章 Linux内核简介

    1.1 Unix的历史 unix的优点 简介,没有繁冗的系统调用 所有东西都被当成了文件对待,对文件和对设备的操作是通过同样的系统调用的接口实现的 内核和相关工具使用C编写,具有很高的可移至性 创建新 ...

  8. PHP小接

    一种是innodb,一种是myisam,两者的主要区别是①myisam不支持事务处理,而innoDB支持事务处理 ②myisam 不支持外键,innoDB支持外键 ③myisam支持全文检索,而inn ...

  9. 3.if结构

    一.简单if结构1.定义:程序的条件判断2.语法:if(条件){ 语句块1}else{ 语句块2}语句块33:说明:条件必须是条件表达式,其结果必须是一个boolean类型 else是可选项,可以不写 ...

  10. Y7000安装驱动显卡问题

    整体 https://blog.csdn.net/la9881275/article/details/86720752 详细 https://blog.csdn.net/luteresa/articl ...