Educational Codeforces Round 64 (Rated for Div. 2) A Inscribed Figures

博客围绕Berland州立大学数学入学测试题展开,题目给出数字序列代表图形类型,图形依次内接,需计算图形接触点数量,可能为无限个。介绍了输入输出格式及示例,最后提到题目有问题取消评分,解题思路是分类讨论并特判312。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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,…,an

, each number is from 1 to 3 and ai≠ai+1 for each valid i. The i-th number represents a type of the i

-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)

-th figure is inscribed into the i

  • -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 i
  • from 2 to n figure i
    • 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 n

    (2≤n≤100

    ) — the number of figures.

    The second line contains n

    integer numbers a1,a2,…,an (1≤ai≤3, ai≠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.

    Examples

    Input

    Copy

    3
    2 1 3
    
    Output

    Copy

    Finite
    7
    
    Input

    Copy

    3
    1 2 3
    
    Output

    Copy

    Infinite
    

    Note

    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.


    cf这题出锅了,最后unrate,╮(╯▽╰)╭

  • 思路:分类讨论,特判312就好了

    #include<cstring>
    #include<cstdio>
    #include<algorithm>
    #include<iostream>
    using namespace std;
    #define ll long long
    #include<queue>
    int main()
    {
        int n;
        while(scanf("%d",&n)!=EOF)
        {
            int a[200]={0},flag=0;
            scanf("%d",&a[1]);int sum=0;
            for(int i=2;i<=n;i++)
            {
                scanf("%d",&a[i]);
                if(a[i]==2&&a[i-1]==3) flag=1;
                if(a[i]==3&&a[i-1]==2) flag=1;
                if((a[i]==2&&a[i-1]==1))
                {
                    if(a[i-2]==3) sum+=2;
                    else sum+=3;
                }
                else if((a[i]==1&&a[i-1]==2)) sum+=3;
                else if((a[i]==1&&a[i-1]==3)||(a[i]==3&&a[i-1]==1)) sum+=4;
            }
            if(flag==1) printf("Infinite\n");
            else
            {
                printf("Finite\n");
                printf("%d\n",sum);
            }
        }
    }

     

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值