Codeforces Round #552 (Div. 3) C题

题目网址:http://codeforces.com/contest/1154/problem/C

题目意思:小猫吃三种食物,A,B,C,一周吃食物的次序是,A,B,C,A,C,B,A,当小猫该天无食物可吃时,就会饿死,现给出a,b,c三个数,表示A,B,C的食物数量,

选择一天开始,问小猫最多可以活到多少天。

题解:首先,在一周时间,A要吃三天,B要吃两天,C要吃两天,先随便选一天开始,当剩下食物不足以撑过一周时停止,再细分剩下的食物数量,看小猫饿

死是经过的最多天数。选择的天数用暴力写即可。

 1 #include<bits/stdc++.h>
 2 using namespace std;
 3 int k[10]={1,2,3,1,3,2,1};
 4 int main()
 5 {
 6     int a,b,c,flag,days=-1;
 7     cin>>a>>b>>c;
 8     int minn=min(min(a/3,b/2),c/2);
 9     a-=minn*3,b-=minn*2,c-=minn*2;
10     minn=minn*7;
11 //    cout<<a<<endl;cout<<b<<endl;cout<<c<<endl;
12     for(int i=0;i<7;i++)
13     {
14         flag=0;
15         int sa=a,sb=b,sc=c;
16         for(int j=0;j<7;j++)
17         {
18             if(k[(i+j)%7]==1)
19             {
20                 if(sa==0) flag=1;
21                 sa--;
22             }
23             else if(k[(i+j)%7]==2)
24             {
25                 if(sb==0) flag=1;
26                 sb--;
27             }
28             else if(k[(i+j)%7]==3)
29             {
30                 if(sc==0) flag=1;
31                 sc--;
32             }
33             if(flag==1) {
34                 days=max(days,j);break;
35             }
36         }
37     }
38     cout<<days+minn<<endl;
39 } 

原文地址:https://www.cnblogs.com/duxing201806/p/10726493.html

时间: 2024-08-30 13:51:18

Codeforces Round #552 (Div. 3) C题的相关文章

Codeforces Round #257 (Div. 2) E题:Jzzhu and Apples 模拟

E. Jzzhu and Apples time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Jzzhu has picked n apples from his big apple tree. All the apples are numbered from 1 to n. Now he wants to sell them to

Codeforces Round #243 (Div. 1) A题

http://codeforces.com/contest/425/problem/A 题目链接: 然后拿出这道题目是很多人不会分析题目,被题目吓坏了,其中包括我自己,想出复杂度,一下就出了啊!真是弱! 直接暴力求出矩阵数值,然后枚举每一个[I,J];再O[N]判断,分配好在[I,J]区间的数和之内的数,再排序下SOLO了 CODE:#include <cstdio> #include <cstring>#include <queue>#include <vect

Codeforces Round #634 (Div. 3) 补题

A. Candies and Two Sisters 签到题,直接输出即可 代码 #include<bits/stdc++.h> #define INF 0x3f3f3f3f typedef long long ll; using namespace std; inline void read(int &p) { p=0;int flag=1;char c=getchar(); while(!isdigit(c)) {if(c=='-') flag=-1;c=getchar();} w

Codeforces Round #396 (Div. 2) D题Mahmoud and a Dictionary(并查集)解题报告

Mahmoud wants to write a new dictionary that contains n words and relations between them. There are two types of relations: synonymy (i. e. the two words mean the same) and antonymy (i. e. the two words mean the opposite). From time to time he discov

Codeforces Round #552(div.3)

Problem: http://codeforces.com/contest/1154 A: 1 /* basic header */ 2 #include <iostream> 3 #include <cstdio> 4 #include <cstdlib> 5 #include <string> 6 #include <cstring> 7 #include <cmath> 8 #include <cstdint> 9

Codeforces Round #552 (Div. 3) Editorial 1154C - Gourmet Cat

链接:https://codeforces.com/contest/1154/problem/C 题意:一只旅行的小猫在特定的星期里吃特定的食物,一四七a,二六b,三五c,现在给三种食物的数量,问小猫最多能活几天. 思路:先看小猫能活几个整星期,因为a在一个星期里占三天,b和c各占两天,所以取min(a/3,b/2,c/2),然后求剩下的,这个时候就可以枚举日子了,从周一枚举到周日,然后模拟一哈就行了,虽然是个水题但我还是没做粗来 代码: 1 //#include<bits/stdc++.h>

Codeforces Round #374 (div.2)遗憾题合集

C.Journey 读错题目了...不是无向图,结果建错图了(喵第4样例是变成无向就会有环的那种图) 并且这题因为要求路径点尽可能多 其实可以规约为限定路径长的拓扑排序,不一定要用最短路做 #pragma comment(linker, "/STACK:1024000000,1024000000") #include<cstdio> #include<cstring> #include<cmath> #include<algorithm>

Codeforces Round #297 (Div. 2) E题. Anya and Cubes (中途相遇法)

题目地址:Anya and Cubes 比赛的时候居然没想起中途相遇法...这题也是属于想起来就很简单系列. 中途相遇法也叫折半搜索.就是处理前一半,把结果储存起来,再处理后一半,然后匹配前一半存储的结果. 代码如下: #include <iostream> #include <string.h> #include <math.h> #include <queue> #include <algorithm> #include <stdlib

Codeforces Round #419 (Div. 1) 补题 CF 815 A-E

A-C传送门 D Karen and Cards 技巧性很强的一道二分优化题 题意很简单 给定n个三元组,和三个维度的上限,问存在多少三元组,使得对于给定的n个三元组中的每一个,必有两个维度严格小于. 首先我们根据一个维度(c维)对n个三元组排序,然后枚举答案在这个维度的取值. 此时序列被分成了两个部分,前半部分 满足所有c大于等于i 后半部分满足所有c严格小于i(即已有一个维度小于) 通过累计,我们知道此时前半部a维的最大值ma和b维的最大值mb. 显然可能存在的三元组答案,必然首先满足a维和