Gourmet Cat
生活随笔
收集整理的這篇文章主要介紹了
Gourmet Cat
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
https://codeforces.com/contest/1154/problem/C
題意:你有只貓,周一、四、日吃魚,周二、六吃兔肉。其余時間吃雞肉。現(xiàn)在你要去旅行,且你準備了a份魚、b份兔肉、c份雞肉。求你在某天出門后這只貓能吃的的最大天數(shù)。
題解:枚舉
1、枚舉開始的星期幾;
2、規(guī)律(這個天數(shù)跟你周幾出門有關
/* *@Author: STZG *@Language: C++ */ #include <bits/stdc++.h> #include<iostream> #include<algorithm> #include<cstdlib> #include<cstring> #include<cstdio> #include<string> #include<vector> #include<bitset> #include<queue> #include<deque> #include<stack> #include<cmath> #include<list> #include<map> #include<set> //#define DEBUG #define RI register int #define endl "\n" using namespace std; typedef long long ll; //typedef __int128 lll; const int N=100000+10; const int M=100000+10; const int MOD=1e9+7; const double PI = acos(-1.0); const double EXP = 1E-8; const int INF = 0x3f3f3f3f; int t,n,m,k,p,l,r,u,v; ll ans,cnt,flag,temp,sum; int a[4],b[8]={0,1,2,3,1,3,2,1},c[4];//fish food, rabbit stew and chicken stakes char str; struct node{}; ll checked(int week){ll day=0;for(int i=1;i<=3;i++)c[i]=a[i];for(int i=week;i<=7;i++){if(c[b[i]])c[b[i]]--,day++;else return i-week;}ll mid=min(c[1]/3,min(c[2]/2,c[3]/2));day+=(mid*7);c[1]-=(mid*3);c[2]-=(mid*2);c[3]-=(mid*2);for(int i=1;i<=7;i++){if(c[b[i]])c[b[i]]--,day++;else break;}return day; }int main() { #ifdef DEBUGfreopen("input.in", "r", stdin);//freopen("output.out", "w", stdout); #endif//ios::sync_with_stdio(false);//cin.tie(0);//cout.tie(0);//scanf("%d",&t);//while(t--){scanf("%d%d%d",&a[1],&a[2],&a[3]);for(int i=1;i<=7;i++){//cout<<checked(i)<<endl;ans=max(ans,checked(i));}cout<<ans<<endl;//}#ifdef DEBUGprintf("Time cost : %lf s\n",(double)clock()/CLOCKS_PER_SEC); #endif//cout << "Hello world!" << endl;return 0; }?
總結(jié)
以上是生活随笔為你收集整理的Gourmet Cat的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Make Them Equal
- 下一篇: Walking Robot