codeforces 1555 A. PizzaForces(思维)

contents:

题意

链接: link.
你要烤n块披萨
一整块的披萨有3种规模
6块的需要15min
8块的需要20min
10块的需要25min
问你需要最少时间烤完

思路

首先
15/6=2.5
20/8=2.5
25/10=2.5
所以性价比都一样
那么8和10存在的意义是什么
假设计划全烤6块的,最后可能会剩下不够6块的,
可能是0到5,再烤一份那就需要15min
如果你把计划中最后一整块换一种规模,每多两块披萨你上升一种规模,这样浪费的最少,时间自然最小,噢原来8和10的存在是为了加钟的

代码

#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 2E5 + 10;
int arr[N];

int main()
{
    int t;
    cin >> t;
    while (t--)
    {
        ll now;
        cin >> now;
        ll res = 0;
        if (now <= 6)
        {
            res = 15;
        }
        else
        {
            res = now / 6 * 15;
            now %= 6;
            if (now == 0)
            {
                res += 0;
            }
            else if (now <= 2)
            {
                res += 5;
            }
            else if (now <= 4)
            {
                res += 10;
            }
            else
            {
                res += 15;
            }
        }
        cout << res << endl;
    }
   // system("pause");
    return 0;
}

代码虽然不简洁,但是好想,顺手就是最快的

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

.0-0.

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值