Codeforces Round #552 (Div. 3) C. Gourmet Cat
Polycarp has a cat and his cat is a real gourmet! Dependent on a day of the week he eats certain type of food:
- on Mondays, Thursdays and Sundays he eats fish food;
- on Tuesdays and Saturdays he eats rabbit stew;
- on other days of week he eats chicken stake.
Polycarp plans to go on a trip and already packed his backpack. His backpack contains:
- aa daily rations of fish food;
- bb daily rations of rabbit stew;
- cc daily rations of chicken stakes.
Polycarp has to choose such day of the week to start his trip that his cat can eat without additional food purchases as long as possible. Print the maximum number of days the cat can eat in a trip without additional food purchases, if Polycarp chooses the day of the week to start his trip optimally.
Input
The first line of the input contains three positive integers aa, bb and cc (1≤a,b,c≤7⋅1081≤a,b,c≤7⋅108) — the number of daily rations of fish food, rabbit stew and chicken stakes in Polycarps backpack correspondingly.
Output
Print the maximum number of days the cat can eat in a trip without additional food purchases, if Polycarp chooses the day of the week to start his trip optimally.
Examples
Input
2 1 1
Output
4
Input
3 2 2
Output
7
Input
1 100 1
Output
3
Input
30 20 10
Output
39
Note
In the first example the best day for start of the trip is Sunday. In this case, during Sunday and Monday the cat will eat fish food, during Tuesday — rabbit stew and during Wednesday — chicken stake. So, after four days of the trip all food will be eaten.
In the second example Polycarp can start his trip in any day of the week. In any case there are food supplies only for one week in Polycarps backpack.
In the third example Polycarp can start his trip in any day, excluding Wednesday, Saturday and Sunday. In this case, the cat will eat three different dishes in three days. Nevertheless that after three days of a trip there will be 9999 portions of rabbit stew in a backpack, can cannot eat anything in fourth day of a trip.
题意:有个人想要去旅行,他的猫吃东西比较挑剔,
周一,周四,周日 吃鱼
周二,周六吃rabbit stew
其他的,也就是周三,周五吃chicken stake
输入三中食品带的量,求最多能吃几天。
解法:首先,我们求出来a/3,b/2,c/2的最小值,是我们的结果,a,b,c减去这几周所需要消耗的,因为可能是周日,周一周二。。。这种情况,所以我们两层for取余7,判断就ok了
#include<bits/stdc++.h>
using namespace std;
int main(){
int a , b , c , ans , n ;
while(~scanf("%d%d%d",&a,&b,&c)){
int mi = min(a/3,min(b/2,c/2));
// cout<<mi<<endl;
ans = mi * 7;
a -= mi * 3;
b -= mi * 2;
c -= mi * 2;
n = -1;
// cout<<a<<"+++++"<<b<<" "<<c<<endl;
for(int i = 1 ; i <= 7 ; i ++){
int cnt = 0;
int a1 = a ;
int b1 = b;
int c1 = c;
// cout<<a1<<" "<<b1<<" "<<c1<<endl;
for(int j = 0 ; j <= 6 ; j ++){
int t = (i + j) % 7;
if(t == 1 || t == 4 || t == 0){
if(a1){
a1 --;
cnt ++;
}
else
break;
}
else if(t == 2 || t == 6){
if(b1){
b1 --;
cnt ++;
}
else
break;
}
else if(t == 3 | t == 5){
if(c1){
c1 -- ;
cnt ++;
}
else
break;
}
}
n = max(n,cnt);
}
// cout<<n<<endl;
cout<<ans+n<<endl;
}
return 0;
}
- 用事实说话,成熟的ORM性能不是瓶颈,灵活性不是问题:EF5.0、PDF.NET5.0、Dapper原理分析与测试手记
- iPhone的Wi-Fi芯片漏洞利用POC公布,赶紧更新系统吧
- No.003 Longest Substring Without Repeating Characters
- 【Spark研究】极简 Spark 入门笔记——安装和第一个回归程序
- 通常Java开发人员如何进行数据排序?
- 消息服务框架使用案例之--大文件上传(断点续传)功能
- Java中三种Set类型用法、性能大比拼
- Android基础总结(5)——数据存储,持久化技术
- 如何突破Windows环境限制打开“命令提示符”
- 【Spark研究】Spark之工作原理
- Java中泛型使用的必要性
- “一切都是消息”--MSF(消息服务框架)之【发布-订阅】模式
- Android基础总结(4)——广播接收器
- “一切都是消息”--MSF(消息服务框架)之【请求-响应】模式(点对点)
- JavaScript 教程
- JavaScript 编辑工具
- JavaScript 与HTML
- JavaScript 与Java
- JavaScript 数据结构
- JavaScript 基本数据类型
- JavaScript 特殊数据类型
- JavaScript 运算符
- JavaScript typeof 运算符
- JavaScript 表达式
- JavaScript 类型转换
- JavaScript 基本语法
- JavaScript 注释
- Javascript 基本处理流程
- Javascript 选择结构
- Javascript if 语句
- Javascript if 语句的嵌套
- Javascript switch 语句
- Javascript 循环结构
- Javascript 循环结构实例
- Javascript 跳转语句
- Javascript 控制语句总结
- Javascript 函数介绍
- Javascript 函数的定义
- Javascript 函数调用
- Javascript 几种特殊的函数
- JavaScript 内置函数简介
- Javascript eval() 函数
- Javascript isFinite() 函数
- Javascript isNaN() 函数
- parseInt() 与 parseFloat()
- escape() 与 unescape()
- Javascript 字符串介绍
- Javascript length属性
- javascript 字符串函数
- Javascript 日期对象简介
- Javascript 日期对象用途
- Date 对象属性和方法
- Javascript 数组是什么
- Javascript 创建数组
- Javascript 数组赋值与取值
- Javascript 数组属性和方法
- AUC、ROC详解:原理、特点&算法
- akka-streams - 从应用角度学习:basic stream parts
- 多线程基础(四):volatile和可见性问题及happens-before原则
- 多线程基础(三):synchronized关键字及java内存模型简介
- 多线程基础(一): 线程概念及生命周期
- Windows下Redis服务的安装及Redis服务的命令行启动和关闭
- git hooks
- 二叉树的层次遍历 II
- Android开发笔记(一百七十三)给安装包APK文件瘦身
- 从 1 到 0 构建博客项目(1) -- 操作系统篇(1)
- Spring JPA 定义查询方法
- 代理工厂的简单应用
- iOS逆向之文件系统
- Kettle构建Hadoop ETL实践(四):建立ETL示例模型
- Java并发总篇