题目大意:
6块披萨要15分钟,8快20分钟,10块25分钟,给出人数,要求每人至少一块,问最短要多长时间
思路:
所有3种披萨都是1分钟2/5块,而且,6,8,10可以组合成6以上的所有偶数,对于奇数向上取整即可,所以答案就是人数乘以5/2,向上取整
#include<bits/stdc++.h>
using namespace std;
int main()
{
int t;
long long peo, piz, min;
cin >> t;
while (t--)
{
cin >> peo;
if (peo < 6)
{
cout << 15 << endl;
}
else
{
if (peo % 2 == 0)
{
min = peo * 5 / 2;
}
else//如果是奇数要注意取整
min = (peo + 1) * 5 / 2;
cout << min << endl;
}
}
return 0;
}
本文解析了Codeforces 1555A问题,该问题涉及根据不同数量披萨的制作时间来计算为满足一定数量的人群需求所需的最短时间。文章提供了详细的解题思路及C++实现代码。
448

被折叠的 条评论
为什么被折叠?



