CF1156A.Inscribed Figures

普及/提高-

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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,…,ana_1, a_2, \dots, a_n, each number is from 11 to 33 and ai≠ai+1a_i \ne a_{i + 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?

伯兰国立大学数学系遭遇了入学新生数学能力的骤降。今年入学数学考试的最高分仅为 8 分(满分 100 分)!因此,校方决定简化考试。

未来的学生只需回答一道题目。他们将被给出一个由整数组成的序列 a1,a2,…,ana_1, a_2, \dots, a_n,其中每个数均取自 {1,2,3}\{1,2,3\},且对所有合法的 ii 均满足 ai≠ai+1a_i \ne a_{i + 1}。第 ii 个数表示第 ii 个图形的类型:

  1. 圆;
  2. 等腰三角形,其高与底边长度相等;
  3. 正方形。

给定序列中的图形被放置在笛卡尔平面上,满足如下条件:

  • 第 (i+1)(i + 1) 个图形内接于第 ii 个图形;
  • 每个三角形的底边平行于 OXOX 轴;
  • 三角形方向为:与底边相对的顶点位于上方;
  • 每个正方形的边均与坐标轴平行;
  • 对每个从 22 到 nn 的 ii,第 ii 个图形在三角形或正方形情形下取最大可能的边长、在圆形情形下取最大可能的半径。

注意:只要固定第一个图形的位置和大小,整个构型即唯一确定。

任务是计算图形之间相互接触的不同点(坐标不一定是整数)的个数。然而有个小技巧:该数目有时为无穷大。但这对你来说应该不难吧?

那么,你能通过这场数学考试,成功进入伯兰国立大学吗?

输入格式

The first line contains a single integer nn (2≤n≤1002 \le n \le 100) — the number of figures.

The second line contains nn integer numbers a1,a2,…,ana_1, a_2, \dots, a_n (1≤ai≤31 \le a_i \le 3, ai≠ai+1a_i \ne a_{i + 1}) — types of the figures.

第一行包含一个整数 nn(2≤n≤1002 \le n \le 100)—— 图形的数量。

第二行包含 nn 个整数 a1,a2,…,ana_1, a_2, \dots, a_n(1≤ai≤31 \le a_i \le 3,且 ai≠ai+1a_i \ne a_{i + 1})—— 各图形的类型。

输出格式

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.

第一行应包含单词“Infinite”(如果图形接触的不同点的数量为无穷多)或“Finite”(否则)。

如果该数量为有限值,则在第二行输出该数值。保证该数值可放入 32 位整数类型中。

输入输出样例

  • 输入#1

    3
    2 1 3

    输出#1

    Finite
    7
  • 输入#2

    3
    1 2 3

    输出#2

    Infinite

说明/提示

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.

The distinct points where figures touch are marked red.

In the second example the triangle and the square touch each other for the whole segment, it contains infinite number of points.

以下是示例的精彩图片。注意:该三角形并非等边三角形,而是等腰三角形,且其高与底边长度相等。因此,它能以唯一的方式嵌入一个正方形中。

图形相互接触的不同点用红色标出。

在第二个示例中,三角形与正方形沿整个线段接触,该线段包含无穷多个点。

输入解题思路,AI测评打分。不知道怎么写?

首页