Educational Codeforces Round 64 (Rated for Div. 2)A. Inscribed Figures【水题】

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:

  1. circle;
  2. isosceles triangle with the length of height equal to the length of base;
  3. square.

The figures of the given sequence are placed somewhere on a Cartesian plane in such a way that:

  • (i+1)(i+1)-th figure is inscribed into the ii-th one;
  • each triangle base is parallel to OX;
  • the triangle is oriented in such a way that the vertex opposite to its base is at the top;
  • each square sides are parallel to the axes;
  • for each ii from 22 to nn figure ii has the maximum possible length of side for triangle and square and maximum radius for circle.

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
#include
#include
#include
#include
#include
#include
using namespace std;
typedef long long ll;
const int maxn = 1e3 + 10;
const int mod = 1e9 + 7;
int a[maxn];

int main()
{
    int n;
    scanf("%d", &n);
    bool flag = false;
    int ans = 0;
    for(int i = 1; i <= n; ++i)
    {
        scanf("%d", &a[i]);
        if(a[i] == 2 && a[i - 1] == 3 || a[i] == 3 && a[i - 1] == 2)
            flag = true;
        if(a[i] == 1 && a[i - 1] == 2 || a[i] == 2 && a[i - 1] == 1)
            ans += 3;
        if(a[i] == 1 && a[i - 1] == 3 || a[i] == 3 && a[i - 1] == 1)
            ans += 4;
        if(i > 2 && a[i] == 2 && a[i - 1] == 1 && a[i - 2] == 3)
            --ans;
    }
    if(flag)
        printf("Infinite\n");
    else
    {
        printf("Finite\n%d\n", ans);

    }
    return 0;
}

 

你可能感兴趣的:(水题,CF)