Codeforces 1080A - Petya and Origami


Codeforces 1080A - Petya and Origami




Petya is having a party soon, and he has decided to invite his nn 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 kk sheets. That is, each notebook contains kk sheets of either red, green, or blue.

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


  22 张红纸 + 55 张绿纸 + 88 张蓝纸 = 11 一个人,每一份彩纸中包含 kk 张彩纸,且只有一种颜色的彩纸。现在有 nn 个人,问最少需要买多少份彩纸。


  模拟一下即可,复杂度 O(1)O(1)


#include <bits/stdc++.h>
typedef long long ll;
int main() {
    ll n, k;
    scanf("%lld%lld\n", &n, &k);
    printf("%lld\n", (n * 2 + k - 1) / k + (n * 5 + k - 1) / k + (n * 8 + k - 1) / k);
    return 0;



Origami is the old Japanese art of folding single sheets of paper into the forms of animals, flowers and other figures. Recently a programmable machine was constructed to make some of the simpler kinds of origami. This machine has a large board with coordinate system drawn on it. First, a square sheet of paper is placed on the board so that the lower left corner has coordinates (0, 0) and the upper right corner has coordinates (100, 100). Then the machine follows the program. The program consists of several steps. Each step is given as a line in the coordinate system at which the origami is to be folded. The line is represented by two points: the paper is folded from right to left when one is facing the second point from the first. The paper on the left side of the line remains in place and the paper on the right side is folded flat on top of it. After the execution of the last step one gets a resulting origami. It is necessary to pierce the origami in order make a hole for hanging. It is important to choose the place for making a hole carefully, because if the origami is too thick in this place it is difficult to make a hole, and if it is too thin it is not strong enough for hanging. Your task is to write a program that computes the number of layers of a paper in the given point.nnnInputnnThe first part of the input file contains a program for the origami machine. The first line contains the number of steps of the program. One line follows for each step of the program. Each line contains fold-line coordinates x1 , y1 , x2 , y2 (real numbers) separated by spaces. The program consists of at most 8 steps. The second part of the input file contains several potential points for making a hole. The first line contains the number of such places and each of the next lines contains coordinates of the point.nnInput contains multiple test cases. Process to the end of file.nnnOutputnnFor each of the potential points write a line containing the number of layers pierced through in this point. Note: Assume that the paper has zero thickness and therefore folds ideally. The pierced hole is a single point. The layers pierced exactly at the border of the paper or at the folded edge (within 0.000001) do not count as pierced layers.nnSeparate output for subsequent test cases with a single blank line.nnnnnSample Inputnn2n-0.5 -0.5 1 1n1 75 0 75n6n10 60n80 60n30 40n10 10n50 50n20 50nnnSample Outputnn4n2n2n0n0n2 问答