codeforces-scrape

Codeforces scraped problems and editorials
git clone git://git.laack.co/codeforces-scrape.git
Log | Files | Refs | README

1156A.md (2784B)


      1 Source: https://codeforces.com/problemset/problem/1156/A
      2 
      3 A. Inscribed Figures
      4 
      5 time limit per test
      6 
      7 1 second
      8 
      9 memory limit per test
     10 
     11 256 megabytes
     12 
     13 input
     14 
     15 standard input
     16 
     17 output
     18 
     19 standard output
     20 
     21 The math faculty of Berland State University has suffered the sudden drop in the math skills of enrolling students. This year the highest grade on the entrance math test was 8. Out of 100! Thus, the decision was made to make the test easier.
     22 
     23 Future students will be asked just a single question. They are given a sequence of integer numbers $a_1, a_2, \dots, a_n$, each number is from $1$ to $3$ and $a_i \ne a_{i + 1}$ for each valid $i$. The $i$-th number represents a type of the $i$-th figure:
     24 
     25 1. circle;
     26 2. isosceles triangle with the length of height equal to the length of base;
     27 3. square.
     28 
     29 The figures of the given sequence are placed somewhere on a Cartesian plane in such a way that:
     30 
     31 * $(i + 1)$-th figure is inscribed into the $i$-th one;
     32 * each triangle base is parallel to OX;
     33 * the triangle is oriented in such a way that the vertex opposite to its base is at the top;
     34 * each square sides are parallel to the axes;
     35 * for each $i$ from $2$ to $n$ figure $i$ has the maximum possible length of side for triangle and square and maximum radius for circle.
     36 
     37 Note that the construction is unique for some fixed position and size of just the first figure.
     38 
     39 The task is to calculate the number of distinct points (not necessarily with integer coordinates) where figures touch. The trick is, however, that the number is sometimes infinite. But that won't make the task difficult for you, will it?
     40 
     41 So can you pass the math test and enroll into Berland State University?
     42 
     43 Input
     44 
     45 The first line contains a single integer $n$ ($2 \le n \le 100$) — the number of figures.
     46 
     47 The second line contains $n$ integer numbers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 3$, $a_i \ne a_{i + 1}$) — types of the figures.
     48 
     49 Output
     50 
     51 The first line should contain either the word "Infinite" if the number of distinct points where figures touch is infinite or "Finite" otherwise.
     52 
     53 If the number is finite than print it in the second line. It's guaranteed that the number fits into 32-bit integer type.
     54 
     55 Examples
     56 
     57 Input
     58 
     59 ```
     60 3
     61 2 1 3
     62 ```
     63 
     64 Output
     65 
     66 ```
     67 Finite
     68 7
     69 ```
     70 
     71 Input
     72 
     73 ```
     74 3
     75 1 2 3
     76 ```
     77 
     78 Output
     79 
     80 ```
     81 Infinite
     82 ```
     83 
     84 Note
     85 
     86 Here are the glorious pictures for the examples. Note that the triangle is not equilateral but just isosceles with the length of height equal to the length of base. Thus it fits into a square in a unique way.
     87 
     88 The distinct points where figures touch are marked red.
     89 
     90 In the second example the triangle and the square touch each other for the whole segment, it contains infinite number of points.
     91 
     92  ![](https://espresso.codeforces.com/725a9f1510b228eb4897612560160815d14ec263.png)