zoukankan      html  css  js  c++  java
  • 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 11 to 33 and aiai+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 (2n1002≤n≤100) — the number of figures.

    The second line contains nn integer numbers a1,a2,,ana1,a2,…,an (1ai31≤ai≤3, aiai+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.

    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.

    感觉这题放在div2的第一题有点难
    题意:给出N个图形(1代表圆, 2代表高等于底的等腰三角形, 3代表矩形, 相邻图形不会相等), 从左到右右边的内接在左边的图形里面, 要求尽量最大而且各种平行的放, 也就是如图. 求图形中点的个数.
    思路:思考每个图形的贡献,特判3 1 2
    代码:
    #include<cstdio>
    #include<cstring>
    #include<iostream>
    #include<algorithm>
    #include<queue>
    #include<stack>
    #include<set>
    #include<map>
    #include<vector>
    #include<cmath>
    
    const int maxn=1e5+5;
    typedef long long ll;
    using namespace std;
    int n;
    int a[maxn];
    int main()
    {
        cin>>n;
        for(int t=1;t<=n;t++)
        {
            scanf("%d",&a[t]);
        }
        int ans=0;
        int flag=0;
        for(int t=2;t<=n;t++)
        {
            if(a[t]==1)
            {
                if(a[t-1]==2) 
                ans+=3;
                else 
                ans+=4;
            }
            else if(a[t]==2)
            {
                if(a[t-1]==1) 
                ans+=3;
                else 
                flag = 1;
            }else
            {
                if(a[t-1]==1) 
                ans+=4;
                else if(a[t-1]==2)
                flag=1;
            }
        }
        for(int t = 3; t <= n; t++)
        {
            if(a[t-2]==3 && a[t-1]==1 && a[t]==2)
                ans--;
        }
        if(flag)
        {
            cout<<"Infinite"<<endl;
        }
        else
        {
            cout<<"Finite"<<endl;
            cout<<ans<<endl;
        }
        return 0;
    }
  • 相关阅读:
    mysql解决插入中文数据显示??
    js实现表单联动
    CSS实现圆角,圆角阴影
    图片预加载实例
    响应式开发学习笔记
    关于viewport
    HTML5 中的结构元素
    linux- deppin 下配置xampp的方法(全)
    # XAMPP 配置密码大全修改默认密码
    Jquery 最大高度
  • 原文地址:https://www.cnblogs.com/Staceyacm/p/10809144.html
Copyright © 2011-2022 走看看