【CCF历年题题解】201709-1 打酱油【贪心】

贪心,能凑够5瓶就先凑,再凑3瓶的

#include <iostream>

using namespace std;

int main()
{
    
    
    int n ;
    cin >> n;
    
    int cnt = n / 10;
    
    int t = cnt;
    if(cnt >= 5) cnt += t / 5 * 2, t %= 5;
    if(t >= 3) cnt += t / 3;
    
    cout << cnt <<endl;
    
    return 0;
}

猜你喜欢

转载自blog.csdn.net/weixin_43154149/article/details/108541500