Codeforces Round#524 A-Petya and Origami (签到题)

原题链接:
http://codeforces.com/contest/1080/problem/A
A. Petya and Origami
time limit per test1 second
memory limit per test256 megabytes
inputstandard input
outputstandard output
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.
题意:
有n个人,每个人都需要2个红色的表,5个绿色的表,8个蓝色的表,现在去买表,每一套表都是由同一种颜色的k个表组成的,问要给所有人需要的表,最少需要买几套?
题解:
签到题,乘法得出每种颜色所需要的个数,除以k向上取整即可。
附上AC代码:

#include <iostream>
#include <cstdio>
using namespace std;

int main()
{
    int n,k;
    int red,green,blue;
    int cnt=0;
    scanf("%d%d",&n,&k);
    red=2*n;
    green=5*n;
    blue=8*n;
    cnt+=red/k;
    if(red%k!=0)
        cnt++;
    cnt+=green/k;
    if(green%k!=0)
        cnt++;
    cnt+=blue/k;
    if(blue%k!=0)
        cnt++;
    printf("%d",cnt);
    return 0;
}

欢迎评论!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值