• 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


    代码过于简单不再写

  • 相关阅读:
    返回一个随机数组中的子数组中的数相加最大的和
    四则运算二之结果
    四则运算二
    UVA 11741 Ignore the Blocks
    UVA 1408 Flight Control
    UVA 10572 Black & White
    CF1138D(545,div2) Camp Schedule
    UVA 1214 Manhattan Wiring
    UVA 11270 Tiling Dominoes
    BZOJ 3261 最大异或和
  • 原文地址:https://www.cnblogs.com/PushyTao/p/13144153.html
Copyright © 2020-2023  润新知