Codeforces 1080A

So I'm trying to solve problem 1080A from codeforces: "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." First I have done all the program, but i was not working. I decided to do the problem step by step. Here I have tried to calcute the number of red copybooks but stuill, it doesn't work.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
  #include<stdio.h>
int main(){
	int n, k, k1, f1;
	scanf("%d %d", &n, &k);
	for(f1=0;f1<=3*n*k;f1=f1+k){
		for(k1=1;k<=3*n*k;k1=k1*f1){
			if(2*n<=k1)
				break;
		}
		if(2*n<=k1)
			break;
	}
	printf("%d", k1);
	return 0;
}
Last edited on
The number needed is:

number of red notebooks needed +
number of green notebooks needed +
number of blue notebooks needed

----------

How many red notebooks are needed?

Number of red sheets needed / number of sheets in a notebook =
2 N / k (rounded up if that's not an exact integer, because you can only buy whole notebooks)

----------

How many green notebooks are needed?

Number of green sheets needed / number of sheets in a notebook =
5 N / k (rounded up if that's not an exact integer, because you can only buy whole notebooks)

----------

How many blue notebooks are needed?

Number of blue sheets needed / number of sheets in a notebook =
8 N / k (rounded up if that's not an exact integer, because you can only buy whole notebooks)
Topic archived. No new replies allowed.