目录

    • Educational Codeforces Round 112 (Rated for Div. 2)-A. PizzaForces
      • Problem Description
      • Input
      • Output
      • Sample Input
      • Sample Onput
  • 题目大意
  • 解题思路
  • AC代码
    • 简化C版本
    • 简化Python版本

Educational Codeforces Round 112 (Rated for Div. 2)-A. PizzaForces

传送门
Time Limit: 2 seconds
Memory Limit: 256 megabytes

Problem Description

PizzaForces is Petya’s favorite pizzeria. PizzaForces makes and sells pizzas of three sizes: small pizzas consist of 666 slices, medium ones consist of 888 slices, and large pizzas consist of 101010 slices each. Baking them takes 151515, 202020 and 252525 minutes, respectively.

Petya’s birthday is today, and nnn 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 nnn slices in total. For example:

Input

The first line contains a single integer ttt (1≤t≤1041 \le t \le 10^41≤t≤104) — the number of testcases.

Each testcase consists of a single line that contains a single integer nnn (1≤n≤10161 \le n \le 10^{16}1≤n≤1016) — the number of Petya’s friends.

Output

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

Sample Input

6
12
15
300
1
9999999999999999
3

Sample Onput

30
40
750
15
25000000000000000
15

题目大意

有3种披萨分别能切成6、8、106、8、106、8、10块,制作它们分别需要15、20、2515、20、2515、20、25分钟。

有nnn个人,没人至少分得一块儿披萨,一次只能烤一种,问最少需要几分钟。

解题思路

不难发现不论披萨能切成几块,每块儿需要的平均时间都是相同的。156=208=2510=2.5\frac{15}{6}=\frac{20}{8}=\frac{25}{10}=2.5615​=820​=1025​=2.5。但是主要就是不能分开做披萨,现在问题转化为如何用6,8,106,8,106,8,10累加出一个最小的比nnn大的数。

首先6,8,106,8,106,8,10都只能加出偶数出来。

因此如果是奇数nnn的话就可以n+1n+1n+1变成偶数,不受影响。都变成偶数后,我们就可以进行约分。

6,8,10,偶数化的n6,8,10,偶数化的n6,8,10,偶数化的n的最大公约数是222,因此就都除以222,变成3,4,5,⌊n+12⌋3,4,5,\lfloor\frac{n+1}{2}\rfloor3,4,5,⌊2n+1​⌋进行比较。

那么3,4,53,4,53,4,5能组合出哪些数呢?

能组合出3∼+∞3\sim+\infin3∼+∞的所有整数。

二三得六,正好比五大一;那七就可以由三和四组成;⋯⋯\cdots\ \cdots⋯ ⋯

也就是说,只要nnn比较大(已经偶数化,可认为没有奇数n),就能正好不多做。
一块儿需要2.52.52.5分钟,因为nnn除以了222,所以现在的一个nnn需要555分钟,正好还把小数避开了

但是如果人数nnn特别小的话至少也得做一块儿最小的(花151515分钟)


AC代码

#include <bits/stdc++.h>
using namespace std;
#define mem(a) memset(a, 0, sizeof(a))
#define dbg(x) cout << #x << " = " << x << endl
#define fi(i, l, r) for (int i = l; i < r; i++)
#define cd(a) scanf("%d", &a)
typedef long long ll;
int main()
{int N;cin>>N;while(N--){ll n;cin>>n;n++; // 若是奇数+1偶数化n/=2; // 与2约分n*=5; // 一块儿5分钟printf("%lld\n",max(n,15ll)); // 总时间至少15分钟}return 0;
}

简化C版本

#include<stdio.h>
#define max(a,b) (a)>(b)?(a):(b)
int main()
{int N;scanf("%d",&N);while(N--){long long n;scanf("%lld",&n);printf("%lld\n",max(15,(n+1)/2*5));}return 0;
}

简化Python版本

N=int(input())
for _ in range(N):print(max(15,(int(input())+1)//2*5))

原创不易,转载请附上原文链接哦~
Tisfy:https://letmefly.blog.csdn.net/article/details/119271272

Educational Codeforces Round 112 (Rated for Div. 2)-A. PizzaForces-题解相关推荐

  1. Educational Codeforces Round 112 (Rated for Div. 2)

    Educational Codeforces Round 112 (Rated for Div. 2) 题号 题目 知识点 A PizzaForces B Two Tables C Coin Rows ...

  2. Educational Codeforces Round 112 (Rated for Div. 2)(A-D)

    Educational Codeforces Round 112 (Rated for Div. 2) A 我写的挺烦的,其实判断一下奇偶数和有没有a>0就行 #include <bits ...

  3. Educational Codeforces Round 133 (Rated for Div. 2)(CD题解)

    Educational Codeforces Round 133 (Rated for Div. 2)CD题解 过AB补CD C. Robot in a Hallway 题意 题意:现有 2∗m 的方 ...

  4. Educational Codeforces Round 112 (Rated for Div. 2)(补题)

    B. Two Tables 题意: 给定一个W*H的矩形,在里面有一个蓝色桌子,坐标(左右顶点)(x1,y1)(x2,y2),然后还要在里面放一个红色桌子,要想放开红色桌子,问你蓝色桌子移动的最小距离 ...

  5. Educational Codeforces Round 112 (Rated for Div. 2) 个人题解

    A. PizzaForces 题意 有三种披萨制作方案:15分钟制作6片.20分钟制作8片和25分钟制作10片. 问制作出至少nnn片披萨要多少分钟 分析 三种方案的效率都一样,都是每分钟制作0.4个 ...

  6. Educational Codeforces Round 137 (Rated for Div. 2)A~D题解

    提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档 文章目录 目录 A. Password B. Permutation Val C. Save the Magazines D. Pro ...

  7. Educational Codeforces Round 140 (Rated for Div. 2)A~D题解

    文章目录 A B C D A 思路:就是三个点如果任意两个点的横坐标相同,并且任意两个点的纵坐标相同的话就不行. #include <cstring> #include <iostr ...

  8. Educational Codeforces Round 113 (Rated for Div. 2) A~D题解

    文章目录 A. Balanced Substring B. Chess Tournament C. Jury Meeting D. Inconvenient Pairs A. Balanced Sub ...

  9. Educational Codeforces Round 127 (Rated for Div. 2) A~E 题解

    A. String Building 题意: 问是否可以用 a a . a a a . b b . b b b aa.aaa.bb.bbb aa.aaa.bb.bbb 拼成所给字符串. 思路: 将原字 ...

最新文章

  1. Docker_Swarm集群系统
  2. Mysql中文乱码问题完美解决方案
  3. gitlab 无法git clone 的一个小点
  4. python图表之pygal入门篇
  5. 开课吧python好吗-如何选择python培训机构?开课吧python培训怎么样?
  6. 23 | MySQL是怎么保证数据不丢的?
  7. 【Python基础】pandas的骚操作:一行 pandas 代码搞定 Excel “条件格式”!
  8. 2912: 奇怪的加法问题(XOR的加法写法)
  9. python抓有趣的东西_Python 五个有趣的彩蛋,你都知道吗?
  10. 在NAS上基础构建云存储系统的两种解决方案
  11. 微机笔记——1.微型计算机概述
  12. 使用MTL库求解矩阵特征值和特征向量
  13. IOI国家集训队1999-2020年论文集(附网盘免费下载链接)
  14. Node.js meitulu图片批量下载爬虫1.01版
  15. 解密android日志xlog,mars的xlog日志文件解析以及日志查看工具介绍
  16. hashCode()和哈希值
  17. 数据库之区分DB\DBMS\DBS
  18. Google搜索使用技巧
  19. 2022-2028年中国海南省在线旅游产业发展动态及投资前景分析报告
  20. 模运算性质-mod (ACM学习笔记)

热门文章

  1. 假想面试题:现在有一串字符串2, 2, 3……,其中字符串中的数字类似于Word文档中的标题级别,最终效果是让它们按照Word文档导航窗格中的标题级别格式进行展示
  2. 清理mysql慢查询日志_MySQL清理慢查询日志slow_log的方法
  3. 北京web前端培训多少钱?好程序员前端培训费用是多少?
  4. Java高并发处理总结
  5. Percona XtraDB Cluster安装
  6. 操作系统:如何通过 ssh 给远程服务器传输文件
  7. ENJ2005-A 半导体分立器件测试系统
  8. 数据库ACID详细解析
  9. Visual Studio 修改安装时提示路径访问被拒绝解决方案
  10. Netty框架入门(一)