Petya and Origami-CodeForces1080A

水题。


Petya is having a party soon, and he has decided to invite his n friends.

He wants to make invitations in the form of origami. For each invitation, he needs two red sheets, five green sheets, and eight blue sheets. The store sells an infinite number of notebooks of each color, but each notebook consists of only one color with k sheets. That is, each notebook contains k sheets of either red, green, or blue.

Find the minimum number of notebooks that Petya needs to buy to invite all n of his friends.

Input
The first line contains two integers n and k (1≤n,k≤108) — the number of Petya’s friends and the number of sheets in each notebook respectively.

Output
Print one number — the minimum number of notebooks that Petya needs to buy.

Examples
Input
3 5
Output
10

Input
15 6
Output
38

Note
In the first example, we need 2 red notebooks, 3 green notebooks, and 5 blue notebooks.

In the second example, we need 5 red notebooks, 13 green notebooks, and 20 blue notebooks.

大意:某人开party要邀请n个人来玩,这人发邀请函用的是精美的折纸,对于每个邀请需要两张红纸,五张绿纸,八张蓝纸。商店里有卖的各种颜色的笔记本,每本笔记本颜色都是单一的且数量足够多,页数都是k。询问对于给定的n和k,这个人需要一共买多少本彩色的笔记本才能满足需求。

一开始没看到有n,本地测试的时候RE了一次。然后加上n就轻松过了。只需要挨个判断各种颜色的本子要买几本就好,和A题几乎一个道理,先算需要几张纸再算要几本。比如说有n个人就要2n张红纸,5n张绿纸,8n张蓝纸,然后再去拿来和k除一下就好。记得判断如果取余有剩余要多买一本。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define maxn 2333
using namespace std;
int k, n;
int main() {
cin >> n >> k;
int ans = 0;
if ((2 * n) % k != 0)
ans += (2 * n) / k + 1;
else
ans += (2 * n) / k;

if ((5 * n) % k != 0)
ans += (5 * n) / k + 1;
else
ans += (5 * n) / k;

if ((8 * n) % k != 0)
ans += (8 * n) / k + 1;
else
ans += (8 * n) / k;
cout << ans;
//system("pause");
return 0;
}

-------------本文结束,感谢您的阅读转载请注明原作者及出处-------------


本文标题:Petya and Origami-CodeForces1080A

文章作者:Shawn Zhou

发布时间:2018年12月14日 - 21:12

最后更新:2019年01月18日 - 19:01

原始链接:http://shawnzhou.xyz/2018/12/14/18-12-14-02/

许可协议: 署名-非商业性使用-禁止演绎 4.0 国际 转载请保留原文链接及作者。

知识无价,码字不易。对您有用,敬请打赏。金额随意,感谢关心。
0%