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.
Future students will be asked just a single question. They are given a sequence of integer numbers a1,a2,…,ana1,a2,…,an, each number is from 11to 33 and ai≠ai+1ai≠ai+1 for each valid ii. The ii-th number represents a type of the ii-th figure:
The figures of the given sequence are placed somewhere on a Cartesian plane in such a way that:
Note that the construction is unique for some fixed position and size of just the first figure.
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?
So can you pass the math test and enroll into Berland State University?
Input
The first line contains a single integer nn (2≤n≤1002≤n≤100) — the number of figures.
The second line contains nn integer numbers a1,a2,…,ana1,a2,…,an (1≤ai≤31≤ai≤3, ai≠ai+1ai≠ai+1) — types of the figures.
Output
The first line should contain either the word "Infinite" if the number of distinct points where figures touch is infinite or "Finite" otherwise.
If the number is finite than print it in the second line. It's guaranteed that the number fits into 32-bit integer type.
思路:题意是给你1圆,2三角形,3是正方形,给你一个序列,问你有多少个相交的点。
不能让三角形与正方形挨着,因为会有无限个点,然后统计圆与正方形,圆与三角形的情况下的点数,然后输出就可以过了。
再然后开始重测,过了2000多人的题变成了百人斩的题,出锅了,这时候想到忽略了一种情况,就是正方形,圆,三角,的情况,这时候要会有点重复,减去就行了。
#include
#include