• Filling Diamonds——codeforces思维题


    You have integer n. Calculate how many ways are there to fully cover belt-like area of 4n−2 triangles with diamond shapes.

    Diamond shape consists of two triangles. You can move, rotate or flip the shape, but you cannot scale it.

    2 coverings are different if some 2 triangles are covered by the same diamond shape in one of them and by different diamond shapes in the other one.

    Please look at pictures below for better understanding.
    在这里插入图片描述
    On the left you can see the diamond shape you will use, and on the right you can see the area you want to fill.
    在这里插入图片描述
    These are the figures of the area you want to fill for n=1,2,3,4.
    outputstandard output
    You have integer n. Calculate how many ways are there to fully cover belt-like area of 4n−2 triangles with diamond shapes.

    Diamond shape consists of two triangles. You can move, rotate or flip the shape, but you cannot scale it.

    2 coverings are different if some 2 triangles are covered by the same diamond shape in one of them and by different diamond shapes in the other one.

    Please look at pictures below for better understanding.

    On the left you can see the diamond shape you will use, and on the right you can see the area you want to fill.
    These are the figures of the area you want to fill for n=1,2,3,4.

    You have to answer t independent test cases.

    Input
    The first line contains a single integer t (1≤t≤104) — the number of test cases.

    Each of the next t lines contains a single integer n (1≤n≤109).

    Output
    For each test case, print the number of ways to fully cover belt-like area of 4n−2 triangles using diamond shape. It can be shown that under given constraints this number of ways doesn’t exceed 1018.

    Example

    input
    2
    2
    1
    output
    2
    1
    

    Note
    在这里插入图片描述
    In the second test case, there is a unique way to fill the area:
    在这里插入图片描述
    WF退役大佬专业解释:https://www.bilibili.com/video/BV1Cg4y1871L?from=search&seid=1821321906952885250
    欢迎三连加关注
    对于第 i 个图形的方法设为ans[i],有两种方式:
    方法一:先选择最左边那个,那么剩下的选择方式就都确定了方法数为1:
    方法二:选择左上角和做下角的两块,那么这种方式就转移到了 i-1 时的方法数量,
    综上可以推出表达式 ans[i] = ans[i-1] +1;
    又因为 ans[1]=1;所以可以轻松得到 ans[i]=i;

    所以输入什么就输出什么本题就会AC


    代码过于简单不再写

  • 相关阅读:
    C# 根据节点索引访问XML配置文件
    C# AE 关于TOCControl
    C# AE 实现点选框选/点击选择要素
    C# AE 合并要素/合并图形/merger功能
    C# AE 对图层筛选要素后显示/只显示符合条件的要素
    css实现垂直水平居中的几种方法
    js中的DOM节点----文本节点
    js中的DOM节点操作---增删改查
    js中的6中继承方式
    js中的原型对象---prototype
  • 原文地址:https://www.cnblogs.com/PushyTao/p/13144153.html
Copyright © 2020-2023  润新知