# C++ code to count number of notebooks to make n origamis

Suppose we have two numbers n and k. In a party there are n invited friends. Amal wants to make invitations in the form of origami. For each invitation, he needs two red papers, five green papers, and eight blue papers. There are infinite number of notebooks of each color, but each notebook consists of only one color with k papers. We have to find the minimum number of notebooks that Amal needs to buy to invite all n of his friends.

So, if the input is like n = 3; k = 5, then the output will be 10, because we need 2 red notebooks, 3 green notebooks, and 5 blue notebooks.

## Steps

To solve this, we will follow these steps −

(2 * n + k - 1) / k + (5 * n + k - 1) / k + (8 * n + k - 1) / k

## Example

Let us see the following implementation to get better understanding −

#include <bits/stdc++.h>
using namespace std;
int solve(int n, int k){
return (2 * n + k - 1) / k + (5 * n + k - 1) / k + (8 * n + k - 1) / k;
}
int main(){
int n = 3;
int k = 5;
cout << solve(n, k) << endl;
}

## Input

3,5

## Output

10

Updated on: 15-Mar-2022

104 Views