分享题目——Pizzaforces(CF)(C++)

文章描述了一个关于Petya生日派对的披萨订购问题,他需要确保每个朋友至少有一片披萨。披萨有三种尺寸,分别对应不同的制作时间和片数。任务是找出在满足至少n片披萨需求的情况下,所需的最短制作时间。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

PizzaForces is Petya's favorite pizzeria. PizzaForces makes and sells pizzas of three sizes: small pizzas consist of 66 slices, medium ones consist of 88 slices, and large pizzas consist of 1010 slices each. Baking them takes 1515 , 2020 and 2525 minutes, respectively.

Petya's birthday is today, and nn of his friends will come, so he decided to make an order from his favorite pizzeria. Petya wants to order so much pizza that each of his friends gets at least one slice of pizza. The cooking time of the order is the total baking time of all the pizzas in the order.

Your task is to determine the minimum number of minutes that is needed to make pizzas containing at least nn slices in total. For example:

  • if 12 friends come to Petya's birthday, he has to order pizzas containing at least 12 slices in total. He can order two small pizzas, containing exactly 12 slices, and the time to bake them is 30 minutes;
  • if 15 friends come to Petya's birthday, he has to order pizzas containing at least 15 slices in total. He can order a small pizza and a large pizza, containing 16 slices, and the time to bake them is 40 minutes;
  • if 300 friends come to Petya's birthday, he has to order pizzas containing at least 300 slices in total. He can order 15 small pizzas, 1010 medium pizzas and 13 large pizzas, in total they contain300 slices, and the total time to bake them is 750 minutes;
  • if only one friend comes to Petya's birthday, he can order a small pizza, and the time to bake it is 15 minutes.

输入格式

The first line contains a single integer t — the number of testcases.

Each testcase consists of a single line that contains a single integer n — the number of Petya's friends.

输出格式

For each testcase, print one integer — the minimum number of minutes that is needed to bake pizzas containing at least n slices in total.

中文翻译:

题意

Petya 喜欢去一个名叫 PizzaForces 的披萨店。这个披萨店有 3 种披萨。分别有 6 片的、 8 片的和 10 片的。 做好分别需要 15,20,25 分钟。Petya 今天过生日,共邀请了 n 个朋友来。Petya 想要订一些披萨。数量不能小于 n 个披萨。请问最少需要多久?(需要的时间是所有披萨所需制作时间的总和。)

输入

第一行一个整数 t 代表数据组数。

接下来 t 行,每行一个 n,代表朋友数。

输出

每行一个整数,代表最少所需制作时间数。

解答:

#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main()
{
	int t ;
	cin >> t;
	while ( t -- )
	{
		int n;
		cin >> n;
		if( n <= 6 ) cout << 15 << endl;
		else
		{
			if( n % 2 == 1 ) n ++;
			
			cout << n / 2 * 5 << endl;
		}
	}
	return 0;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值